
_sh:     file format elf32-i386


Disassembly of section .text:

00000000 <main>:
  return 0;
}

int
main(void)
{
       0:	55                   	push   %ebp
       1:	89 e5                	mov    %esp,%ebp
       3:	83 e4 f0             	and    $0xfffffff0,%esp
       6:	83 ec 10             	sub    $0x10,%esp
  static char buf[100];
  int fd;
  
  // Assumes three file descriptors open.
  while((fd = open("console", O_RDWR)) >= 0){
       9:	eb 0e                	jmp    19 <main+0x19>
       b:	90                   	nop
       c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
    if(fd >= 3){
      10:	83 f8 02             	cmp    $0x2,%eax
      13:	0f 8f cd 00 00 00    	jg     e6 <main+0xe6>
{
  static char buf[100];
  int fd;
  
  // Assumes three file descriptors open.
  while((fd = open("console", O_RDWR)) >= 0){
      19:	c7 44 24 04 02 00 00 	movl   $0x2,0x4(%esp)
      20:	00 
      21:	c7 04 24 19 13 00 00 	movl   $0x1319,(%esp)
      28:	e8 77 0e 00 00       	call   ea4 <open>
      2d:	85 c0                	test   %eax,%eax
      2f:	79 df                	jns    10 <main+0x10>
      31:	eb 23                	jmp    56 <main+0x56>
      33:	90                   	nop
      34:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
    }
  }
  
  // Read and run input commands.
  while(getcmd(buf, sizeof(buf)) >= 0){
    if(buf[0] == 'c' && buf[1] == 'd' && buf[2] == ' '){
      38:	80 3d 62 19 00 00 20 	cmpb   $0x20,0x1962
      3f:	90                   	nop
      40:	74 60                	je     a2 <main+0xa2>
      42:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
      buf[strlen(buf)-1] = 0;  // chop \n
      if(chdir(buf+3) < 0)
        printf(2, "cannot cd %s\n", buf+3);
      continue;
    }
    if(fork1() == 0)
      48:	e8 43 01 00 00       	call   190 <fork1>
      4d:	85 c0                	test   %eax,%eax
      4f:	74 38                	je     89 <main+0x89>
      runcmd(parsecmd(buf));
    wait();
      51:	e8 16 0e 00 00       	call   e6c <wait>
      break;
    }
  }
  
  // Read and run input commands.
  while(getcmd(buf, sizeof(buf)) >= 0){
      56:	c7 44 24 04 64 00 00 	movl   $0x64,0x4(%esp)
      5d:	00 
      5e:	c7 04 24 60 19 00 00 	movl   $0x1960,(%esp)
      65:	e8 96 00 00 00       	call   100 <getcmd>
      6a:	85 c0                	test   %eax,%eax
      6c:	78 2f                	js     9d <main+0x9d>
    if(buf[0] == 'c' && buf[1] == 'd' && buf[2] == ' '){
      6e:	80 3d 60 19 00 00 63 	cmpb   $0x63,0x1960
      75:	75 d1                	jne    48 <main+0x48>
      77:	80 3d 61 19 00 00 64 	cmpb   $0x64,0x1961
      7e:	74 b8                	je     38 <main+0x38>
      buf[strlen(buf)-1] = 0;  // chop \n
      if(chdir(buf+3) < 0)
        printf(2, "cannot cd %s\n", buf+3);
      continue;
    }
    if(fork1() == 0)
      80:	e8 0b 01 00 00       	call   190 <fork1>
      85:	85 c0                	test   %eax,%eax
      87:	75 c8                	jne    51 <main+0x51>
      runcmd(parsecmd(buf));
      89:	c7 04 24 60 19 00 00 	movl   $0x1960,(%esp)
      90:	e8 eb 0a 00 00       	call   b80 <parsecmd>
      95:	89 04 24             	mov    %eax,(%esp)
      98:	e8 13 01 00 00       	call   1b0 <runcmd>
    wait();
  }
  exit();
      9d:	e8 c2 0d 00 00       	call   e64 <exit>
  // Read and run input commands.
  while(getcmd(buf, sizeof(buf)) >= 0){
    if(buf[0] == 'c' && buf[1] == 'd' && buf[2] == ' '){
      // Clumsy but will have to do for now.
      // Chdir has no effect on the parent if run in the child.
      buf[strlen(buf)-1] = 0;  // chop \n
      a2:	c7 04 24 60 19 00 00 	movl   $0x1960,(%esp)
      a9:	e8 d2 0b 00 00       	call   c80 <strlen>
      if(chdir(buf+3) < 0)
      ae:	c7 04 24 63 19 00 00 	movl   $0x1963,(%esp)
  // Read and run input commands.
  while(getcmd(buf, sizeof(buf)) >= 0){
    if(buf[0] == 'c' && buf[1] == 'd' && buf[2] == ' '){
      // Clumsy but will have to do for now.
      // Chdir has no effect on the parent if run in the child.
      buf[strlen(buf)-1] = 0;  // chop \n
      b5:	c6 80 5f 19 00 00 00 	movb   $0x0,0x195f(%eax)
      if(chdir(buf+3) < 0)
      bc:	e8 13 0e 00 00       	call   ed4 <chdir>
      c1:	85 c0                	test   %eax,%eax
      c3:	79 91                	jns    56 <main+0x56>
        printf(2, "cannot cd %s\n", buf+3);
      c5:	c7 44 24 08 63 19 00 	movl   $0x1963,0x8(%esp)
      cc:	00 
      cd:	c7 44 24 04 21 13 00 	movl   $0x1321,0x4(%esp)
      d4:	00 
      d5:	c7 04 24 02 00 00 00 	movl   $0x2,(%esp)
      dc:	e8 cf 0e 00 00       	call   fb0 <printf>
      e1:	e9 70 ff ff ff       	jmp    56 <main+0x56>
  int fd;
  
  // Assumes three file descriptors open.
  while((fd = open("console", O_RDWR)) >= 0){
    if(fd >= 3){
      close(fd);
      e6:	89 04 24             	mov    %eax,(%esp)
      e9:	e8 9e 0d 00 00       	call   e8c <close>
      ee:	66 90                	xchg   %ax,%ax
      break;
      f0:	e9 61 ff ff ff       	jmp    56 <main+0x56>
      f5:	90                   	nop
      f6:	90                   	nop
      f7:	90                   	nop
      f8:	90                   	nop
      f9:	90                   	nop
      fa:	90                   	nop
      fb:	90                   	nop
      fc:	90                   	nop
      fd:	90                   	nop
      fe:	90                   	nop
      ff:	90                   	nop

00000100 <getcmd>:
  exit();
}

int
getcmd(char *buf, int nbuf)
{
     100:	83 ec 1c             	sub    $0x1c,%esp
     103:	89 5c 24 14          	mov    %ebx,0x14(%esp)
     107:	8b 5c 24 20          	mov    0x20(%esp),%ebx
     10b:	89 74 24 18          	mov    %esi,0x18(%esp)
     10f:	8b 74 24 24          	mov    0x24(%esp),%esi
  printf(2, "$ ");
     113:	c7 44 24 04 78 12 00 	movl   $0x1278,0x4(%esp)
     11a:	00 
     11b:	c7 04 24 02 00 00 00 	movl   $0x2,(%esp)
     122:	e8 89 0e 00 00       	call   fb0 <printf>
  memset(buf, 0, nbuf);
     127:	89 74 24 08          	mov    %esi,0x8(%esp)
     12b:	89 1c 24             	mov    %ebx,(%esp)
     12e:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
     135:	00 
     136:	e8 65 0b 00 00       	call   ca0 <memset>
  gets(buf, nbuf);
     13b:	89 74 24 04          	mov    %esi,0x4(%esp)
     13f:	89 1c 24             	mov    %ebx,(%esp)
     142:	e8 b9 0b 00 00       	call   d00 <gets>
  if(buf[0] == 0) // EOF
    return -1;
  return 0;
}
     147:	8b 74 24 18          	mov    0x18(%esp),%esi
{
  printf(2, "$ ");
  memset(buf, 0, nbuf);
  gets(buf, nbuf);
  if(buf[0] == 0) // EOF
    return -1;
     14b:	80 3b 01             	cmpb   $0x1,(%ebx)
  return 0;
}
     14e:	8b 5c 24 14          	mov    0x14(%esp),%ebx
{
  printf(2, "$ ");
  memset(buf, 0, nbuf);
  gets(buf, nbuf);
  if(buf[0] == 0) // EOF
    return -1;
     152:	19 c0                	sbb    %eax,%eax
  return 0;
}
     154:	83 c4 1c             	add    $0x1c,%esp
     157:	c3                   	ret    
     158:	90                   	nop
     159:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi

00000160 <panic>:
  exit();
}

void
panic(char *s)
{
     160:	83 ec 1c             	sub    $0x1c,%esp
  printf(2, "%s\n", s);
     163:	8b 44 24 20          	mov    0x20(%esp),%eax
     167:	c7 44 24 04 15 13 00 	movl   $0x1315,0x4(%esp)
     16e:	00 
     16f:	c7 04 24 02 00 00 00 	movl   $0x2,(%esp)
     176:	89 44 24 08          	mov    %eax,0x8(%esp)
     17a:	e8 31 0e 00 00       	call   fb0 <printf>
  exit();
     17f:	e8 e0 0c 00 00       	call   e64 <exit>
     184:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
     18a:	8d bf 00 00 00 00    	lea    0x0(%edi),%edi

00000190 <fork1>:
}

int
fork1(void)
{
     190:	83 ec 1c             	sub    $0x1c,%esp
  int pid;
  
  pid = fork();
     193:	e8 c4 0c 00 00       	call   e5c <fork>
  if(pid == -1)
     198:	83 f8 ff             	cmp    $0xffffffff,%eax
     19b:	74 04                	je     1a1 <fork1+0x11>
    panic("fork");
  return pid;
}
     19d:	83 c4 1c             	add    $0x1c,%esp
     1a0:	c3                   	ret    
{
  int pid;
  
  pid = fork();
  if(pid == -1)
    panic("fork");
     1a1:	c7 04 24 7b 12 00 00 	movl   $0x127b,(%esp)
     1a8:	e8 b3 ff ff ff       	call   160 <panic>
     1ad:	8d 76 00             	lea    0x0(%esi),%esi

000001b0 <runcmd>:
struct cmd *parsecmd(char*);

// Execute cmd.  Never returns.
void
runcmd(struct cmd *cmd)
{
     1b0:	53                   	push   %ebx
     1b1:	83 ec 28             	sub    $0x28,%esp
     1b4:	8b 5c 24 30          	mov    0x30(%esp),%ebx
  struct execcmd *ecmd;
  struct listcmd *lcmd;
  struct pipecmd *pcmd;
  struct redircmd *rcmd;

  if(cmd == 0)
     1b8:	85 db                	test   %ebx,%ebx
     1ba:	74 63                	je     21f <runcmd+0x6f>
    exit();
  
  switch(cmd->type){
     1bc:	83 3b 05             	cmpl   $0x5,(%ebx)
     1bf:	76 64                	jbe    225 <runcmd+0x75>
  default:
    panic("runcmd");
     1c1:	c7 04 24 80 12 00 00 	movl   $0x1280,(%esp)
     1c8:	e8 93 ff ff ff       	call   160 <panic>
    runcmd(lcmd->right);
    break;

  case PIPE:
    pcmd = (struct pipecmd*)cmd;
    if(pipe(p) < 0)
     1cd:	8d 44 24 18          	lea    0x18(%esp),%eax
     1d1:	89 04 24             	mov    %eax,(%esp)
     1d4:	e8 9b 0c 00 00       	call   e74 <pipe>
     1d9:	85 c0                	test   %eax,%eax
     1db:	0f 88 fa 00 00 00    	js     2db <runcmd+0x12b>
      panic("pipe");
    if(fork1() == 0){
     1e1:	e8 aa ff ff ff       	call   190 <fork1>
     1e6:	85 c0                	test   %eax,%eax
     1e8:	0f 84 34 01 00 00    	je     322 <runcmd+0x172>
     1ee:	66 90                	xchg   %ax,%ax
      dup(p[1]);
      close(p[0]);
      close(p[1]);
      runcmd(pcmd->left);
    }
    if(fork1() == 0){
     1f0:	e8 9b ff ff ff       	call   190 <fork1>
     1f5:	85 c0                	test   %eax,%eax
     1f7:	0f 84 ea 00 00 00    	je     2e7 <runcmd+0x137>
      dup(p[0]);
      close(p[0]);
      close(p[1]);
      runcmd(pcmd->right);
    }
    close(p[0]);
     1fd:	8b 44 24 18          	mov    0x18(%esp),%eax
     201:	89 04 24             	mov    %eax,(%esp)
     204:	e8 83 0c 00 00       	call   e8c <close>
    close(p[1]);
     209:	8b 44 24 1c          	mov    0x1c(%esp),%eax
     20d:	89 04 24             	mov    %eax,(%esp)
     210:	e8 77 0c 00 00       	call   e8c <close>
    wait();
     215:	e8 52 0c 00 00       	call   e6c <wait>
    wait();
     21a:	e8 4d 0c 00 00       	call   e6c <wait>
     21f:	90                   	nop
    bcmd = (struct backcmd*)cmd;
    if(fork1() == 0)
      runcmd(bcmd->cmd);
    break;
  }
  exit();
     220:	e8 3f 0c 00 00       	call   e64 <exit>
  struct redircmd *rcmd;

  if(cmd == 0)
    exit();
  
  switch(cmd->type){
     225:	8b 03                	mov    (%ebx),%eax
     227:	ff 24 85 30 13 00 00 	jmp    *0x1330(,%eax,4)
     22e:	66 90                	xchg   %ax,%ax
    wait();
    break;
    
  case BACK:
    bcmd = (struct backcmd*)cmd;
    if(fork1() == 0)
     230:	e8 5b ff ff ff       	call   190 <fork1>
     235:	85 c0                	test   %eax,%eax
     237:	75 e6                	jne    21f <runcmd+0x6f>
     239:	eb 3f                	jmp    27a <runcmd+0xca>
     23b:	90                   	nop
     23c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
    runcmd(rcmd->cmd);
    break;

  case LIST:
    lcmd = (struct listcmd*)cmd;
    if(fork1() == 0)
     240:	e8 4b ff ff ff       	call   190 <fork1>
     245:	85 c0                	test   %eax,%eax
     247:	74 31                	je     27a <runcmd+0xca>
      runcmd(lcmd->left);
    wait();
     249:	e8 1e 0c 00 00       	call   e6c <wait>
    runcmd(lcmd->right);
     24e:	8b 43 08             	mov    0x8(%ebx),%eax
     251:	89 04 24             	mov    %eax,(%esp)
     254:	e8 57 ff ff ff       	call   1b0 <runcmd>
    printf(2, "exec %s failed\n", ecmd->argv[0]);
    break;

  case REDIR:
    rcmd = (struct redircmd*)cmd;
    close(rcmd->fd);
     259:	8b 43 14             	mov    0x14(%ebx),%eax
     25c:	89 04 24             	mov    %eax,(%esp)
     25f:	e8 28 0c 00 00       	call   e8c <close>
    if(open(rcmd->file, rcmd->mode) < 0){
     264:	8b 43 10             	mov    0x10(%ebx),%eax
     267:	89 44 24 04          	mov    %eax,0x4(%esp)
     26b:	8b 43 08             	mov    0x8(%ebx),%eax
     26e:	89 04 24             	mov    %eax,(%esp)
     271:	e8 2e 0c 00 00       	call   ea4 <open>
     276:	85 c0                	test   %eax,%eax
     278:	78 41                	js     2bb <runcmd+0x10b>
    break;
    
  case BACK:
    bcmd = (struct backcmd*)cmd;
    if(fork1() == 0)
      runcmd(bcmd->cmd);
     27a:	8b 43 04             	mov    0x4(%ebx),%eax
     27d:	89 04 24             	mov    %eax,(%esp)
     280:	e8 2b ff ff ff       	call   1b0 <runcmd>
  default:
    panic("runcmd");

  case EXEC:
    ecmd = (struct execcmd*)cmd;
    if(ecmd->argv[0] == 0)
     285:	8b 43 04             	mov    0x4(%ebx),%eax
     288:	85 c0                	test   %eax,%eax
     28a:	74 93                	je     21f <runcmd+0x6f>
      exit();
    exec(ecmd->argv[0], ecmd->argv);
     28c:	8d 53 04             	lea    0x4(%ebx),%edx
     28f:	89 54 24 04          	mov    %edx,0x4(%esp)
     293:	89 04 24             	mov    %eax,(%esp)
     296:	e8 01 0c 00 00       	call   e9c <exec>
    printf(2, "exec %s failed\n", ecmd->argv[0]);
     29b:	8b 43 04             	mov    0x4(%ebx),%eax
     29e:	c7 44 24 04 87 12 00 	movl   $0x1287,0x4(%esp)
     2a5:	00 
     2a6:	c7 04 24 02 00 00 00 	movl   $0x2,(%esp)
     2ad:	89 44 24 08          	mov    %eax,0x8(%esp)
     2b1:	e8 fa 0c 00 00       	call   fb0 <printf>
    break;
     2b6:	e9 64 ff ff ff       	jmp    21f <runcmd+0x6f>

  case REDIR:
    rcmd = (struct redircmd*)cmd;
    close(rcmd->fd);
    if(open(rcmd->file, rcmd->mode) < 0){
      printf(2, "open %s failed\n", rcmd->file);
     2bb:	8b 43 08             	mov    0x8(%ebx),%eax
     2be:	c7 44 24 04 97 12 00 	movl   $0x1297,0x4(%esp)
     2c5:	00 
     2c6:	c7 04 24 02 00 00 00 	movl   $0x2,(%esp)
     2cd:	89 44 24 08          	mov    %eax,0x8(%esp)
     2d1:	e8 da 0c 00 00       	call   fb0 <printf>
      exit();
     2d6:	e8 89 0b 00 00       	call   e64 <exit>
    break;

  case PIPE:
    pcmd = (struct pipecmd*)cmd;
    if(pipe(p) < 0)
      panic("pipe");
     2db:	c7 04 24 a7 12 00 00 	movl   $0x12a7,(%esp)
     2e2:	e8 79 fe ff ff       	call   160 <panic>
      close(p[0]);
      close(p[1]);
      runcmd(pcmd->left);
    }
    if(fork1() == 0){
      close(0);
     2e7:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
     2ee:	e8 99 0b 00 00       	call   e8c <close>
      dup(p[0]);
     2f3:	8b 44 24 18          	mov    0x18(%esp),%eax
     2f7:	89 04 24             	mov    %eax,(%esp)
     2fa:	e8 dd 0b 00 00       	call   edc <dup>
      close(p[0]);
     2ff:	8b 44 24 18          	mov    0x18(%esp),%eax
     303:	89 04 24             	mov    %eax,(%esp)
     306:	e8 81 0b 00 00       	call   e8c <close>
      close(p[1]);
     30b:	8b 44 24 1c          	mov    0x1c(%esp),%eax
     30f:	89 04 24             	mov    %eax,(%esp)
     312:	e8 75 0b 00 00       	call   e8c <close>
      runcmd(pcmd->right);
     317:	8b 43 08             	mov    0x8(%ebx),%eax
     31a:	89 04 24             	mov    %eax,(%esp)
     31d:	e8 8e fe ff ff       	call   1b0 <runcmd>
  case PIPE:
    pcmd = (struct pipecmd*)cmd;
    if(pipe(p) < 0)
      panic("pipe");
    if(fork1() == 0){
      close(1);
     322:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
     329:	e8 5e 0b 00 00       	call   e8c <close>
      dup(p[1]);
     32e:	8b 44 24 1c          	mov    0x1c(%esp),%eax
     332:	89 04 24             	mov    %eax,(%esp)
     335:	e8 a2 0b 00 00       	call   edc <dup>
      close(p[0]);
     33a:	8b 44 24 18          	mov    0x18(%esp),%eax
     33e:	89 04 24             	mov    %eax,(%esp)
     341:	e8 46 0b 00 00       	call   e8c <close>
      close(p[1]);
     346:	8b 44 24 1c          	mov    0x1c(%esp),%eax
     34a:	89 04 24             	mov    %eax,(%esp)
     34d:	e8 3a 0b 00 00       	call   e8c <close>
      runcmd(pcmd->left);
     352:	8b 43 04             	mov    0x4(%ebx),%eax
     355:	89 04 24             	mov    %eax,(%esp)
     358:	e8 53 fe ff ff       	call   1b0 <runcmd>
     35d:	8d 76 00             	lea    0x0(%esi),%esi

00000360 <execcmd>:

// Constructors

struct cmd*
execcmd(void)
{
     360:	53                   	push   %ebx
     361:	83 ec 18             	sub    $0x18,%esp
  struct execcmd *cmd;

  cmd = malloc(sizeof(*cmd));
     364:	c7 04 24 54 00 00 00 	movl   $0x54,(%esp)
     36b:	e8 20 0e 00 00       	call   1190 <malloc>
  memset(cmd, 0, sizeof(*cmd));
     370:	c7 44 24 08 54 00 00 	movl   $0x54,0x8(%esp)
     377:	00 
     378:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
     37f:	00 
struct cmd*
execcmd(void)
{
  struct execcmd *cmd;

  cmd = malloc(sizeof(*cmd));
     380:	89 c3                	mov    %eax,%ebx
  memset(cmd, 0, sizeof(*cmd));
     382:	89 04 24             	mov    %eax,(%esp)
     385:	e8 16 09 00 00       	call   ca0 <memset>
  cmd->type = EXEC;
  return (struct cmd*)cmd;
}
     38a:	89 d8                	mov    %ebx,%eax
{
  struct execcmd *cmd;

  cmd = malloc(sizeof(*cmd));
  memset(cmd, 0, sizeof(*cmd));
  cmd->type = EXEC;
     38c:	c7 03 01 00 00 00    	movl   $0x1,(%ebx)
  return (struct cmd*)cmd;
}
     392:	83 c4 18             	add    $0x18,%esp
     395:	5b                   	pop    %ebx
     396:	c3                   	ret    
     397:	89 f6                	mov    %esi,%esi
     399:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

000003a0 <redircmd>:

struct cmd*
redircmd(struct cmd *subcmd, char *file, char *efile, int mode, int fd)
{
     3a0:	53                   	push   %ebx
     3a1:	83 ec 18             	sub    $0x18,%esp
  struct redircmd *cmd;

  cmd = malloc(sizeof(*cmd));
     3a4:	c7 04 24 18 00 00 00 	movl   $0x18,(%esp)
     3ab:	e8 e0 0d 00 00       	call   1190 <malloc>
  memset(cmd, 0, sizeof(*cmd));
     3b0:	c7 44 24 08 18 00 00 	movl   $0x18,0x8(%esp)
     3b7:	00 
     3b8:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
     3bf:	00 
struct cmd*
redircmd(struct cmd *subcmd, char *file, char *efile, int mode, int fd)
{
  struct redircmd *cmd;

  cmd = malloc(sizeof(*cmd));
     3c0:	89 c3                	mov    %eax,%ebx
  memset(cmd, 0, sizeof(*cmd));
     3c2:	89 04 24             	mov    %eax,(%esp)
     3c5:	e8 d6 08 00 00       	call   ca0 <memset>
  cmd->type = REDIR;
  cmd->cmd = subcmd;
     3ca:	8b 44 24 20          	mov    0x20(%esp),%eax
{
  struct redircmd *cmd;

  cmd = malloc(sizeof(*cmd));
  memset(cmd, 0, sizeof(*cmd));
  cmd->type = REDIR;
     3ce:	c7 03 02 00 00 00    	movl   $0x2,(%ebx)
  cmd->cmd = subcmd;
     3d4:	89 43 04             	mov    %eax,0x4(%ebx)
  cmd->file = file;
     3d7:	8b 44 24 24          	mov    0x24(%esp),%eax
     3db:	89 43 08             	mov    %eax,0x8(%ebx)
  cmd->efile = efile;
     3de:	8b 44 24 28          	mov    0x28(%esp),%eax
     3e2:	89 43 0c             	mov    %eax,0xc(%ebx)
  cmd->mode = mode;
     3e5:	8b 44 24 2c          	mov    0x2c(%esp),%eax
     3e9:	89 43 10             	mov    %eax,0x10(%ebx)
  cmd->fd = fd;
     3ec:	8b 44 24 30          	mov    0x30(%esp),%eax
     3f0:	89 43 14             	mov    %eax,0x14(%ebx)
  return (struct cmd*)cmd;
}
     3f3:	83 c4 18             	add    $0x18,%esp
     3f6:	89 d8                	mov    %ebx,%eax
     3f8:	5b                   	pop    %ebx
     3f9:	c3                   	ret    
     3fa:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi

00000400 <pipecmd>:

struct cmd*
pipecmd(struct cmd *left, struct cmd *right)
{
     400:	53                   	push   %ebx
     401:	83 ec 18             	sub    $0x18,%esp
  struct pipecmd *cmd;

  cmd = malloc(sizeof(*cmd));
     404:	c7 04 24 0c 00 00 00 	movl   $0xc,(%esp)
     40b:	e8 80 0d 00 00       	call   1190 <malloc>
  memset(cmd, 0, sizeof(*cmd));
     410:	c7 44 24 08 0c 00 00 	movl   $0xc,0x8(%esp)
     417:	00 
     418:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
     41f:	00 
struct cmd*
pipecmd(struct cmd *left, struct cmd *right)
{
  struct pipecmd *cmd;

  cmd = malloc(sizeof(*cmd));
     420:	89 c3                	mov    %eax,%ebx
  memset(cmd, 0, sizeof(*cmd));
     422:	89 04 24             	mov    %eax,(%esp)
     425:	e8 76 08 00 00       	call   ca0 <memset>
  cmd->type = PIPE;
  cmd->left = left;
     42a:	8b 44 24 20          	mov    0x20(%esp),%eax
{
  struct pipecmd *cmd;

  cmd = malloc(sizeof(*cmd));
  memset(cmd, 0, sizeof(*cmd));
  cmd->type = PIPE;
     42e:	c7 03 03 00 00 00    	movl   $0x3,(%ebx)
  cmd->left = left;
     434:	89 43 04             	mov    %eax,0x4(%ebx)
  cmd->right = right;
     437:	8b 44 24 24          	mov    0x24(%esp),%eax
     43b:	89 43 08             	mov    %eax,0x8(%ebx)
  return (struct cmd*)cmd;
}
     43e:	83 c4 18             	add    $0x18,%esp
     441:	89 d8                	mov    %ebx,%eax
     443:	5b                   	pop    %ebx
     444:	c3                   	ret    
     445:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
     449:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00000450 <listcmd>:

struct cmd*
listcmd(struct cmd *left, struct cmd *right)
{
     450:	53                   	push   %ebx
     451:	83 ec 18             	sub    $0x18,%esp
  struct listcmd *cmd;

  cmd = malloc(sizeof(*cmd));
     454:	c7 04 24 0c 00 00 00 	movl   $0xc,(%esp)
     45b:	e8 30 0d 00 00       	call   1190 <malloc>
  memset(cmd, 0, sizeof(*cmd));
     460:	c7 44 24 08 0c 00 00 	movl   $0xc,0x8(%esp)
     467:	00 
     468:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
     46f:	00 
struct cmd*
listcmd(struct cmd *left, struct cmd *right)
{
  struct listcmd *cmd;

  cmd = malloc(sizeof(*cmd));
     470:	89 c3                	mov    %eax,%ebx
  memset(cmd, 0, sizeof(*cmd));
     472:	89 04 24             	mov    %eax,(%esp)
     475:	e8 26 08 00 00       	call   ca0 <memset>
  cmd->type = LIST;
  cmd->left = left;
     47a:	8b 44 24 20          	mov    0x20(%esp),%eax
{
  struct listcmd *cmd;

  cmd = malloc(sizeof(*cmd));
  memset(cmd, 0, sizeof(*cmd));
  cmd->type = LIST;
     47e:	c7 03 04 00 00 00    	movl   $0x4,(%ebx)
  cmd->left = left;
     484:	89 43 04             	mov    %eax,0x4(%ebx)
  cmd->right = right;
     487:	8b 44 24 24          	mov    0x24(%esp),%eax
     48b:	89 43 08             	mov    %eax,0x8(%ebx)
  return (struct cmd*)cmd;
}
     48e:	83 c4 18             	add    $0x18,%esp
     491:	89 d8                	mov    %ebx,%eax
     493:	5b                   	pop    %ebx
     494:	c3                   	ret    
     495:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
     499:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

000004a0 <backcmd>:

struct cmd*
backcmd(struct cmd *subcmd)
{
     4a0:	53                   	push   %ebx
     4a1:	83 ec 18             	sub    $0x18,%esp
  struct backcmd *cmd;

  cmd = malloc(sizeof(*cmd));
     4a4:	c7 04 24 08 00 00 00 	movl   $0x8,(%esp)
     4ab:	e8 e0 0c 00 00       	call   1190 <malloc>
  memset(cmd, 0, sizeof(*cmd));
     4b0:	c7 44 24 08 08 00 00 	movl   $0x8,0x8(%esp)
     4b7:	00 
     4b8:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
     4bf:	00 
struct cmd*
backcmd(struct cmd *subcmd)
{
  struct backcmd *cmd;

  cmd = malloc(sizeof(*cmd));
     4c0:	89 c3                	mov    %eax,%ebx
  memset(cmd, 0, sizeof(*cmd));
     4c2:	89 04 24             	mov    %eax,(%esp)
     4c5:	e8 d6 07 00 00       	call   ca0 <memset>
  cmd->type = BACK;
  cmd->cmd = subcmd;
     4ca:	8b 44 24 20          	mov    0x20(%esp),%eax
{
  struct backcmd *cmd;

  cmd = malloc(sizeof(*cmd));
  memset(cmd, 0, sizeof(*cmd));
  cmd->type = BACK;
     4ce:	c7 03 05 00 00 00    	movl   $0x5,(%ebx)
  cmd->cmd = subcmd;
     4d4:	89 43 04             	mov    %eax,0x4(%ebx)
  return (struct cmd*)cmd;
}
     4d7:	83 c4 18             	add    $0x18,%esp
     4da:	89 d8                	mov    %ebx,%eax
     4dc:	5b                   	pop    %ebx
     4dd:	c3                   	ret    
     4de:	66 90                	xchg   %ax,%ax

000004e0 <gettoken>:
char whitespace[] = " \t\r\n\v";
char symbols[] = "<|>&;()";

int
gettoken(char **ps, char *es, char **q, char **eq)
{
     4e0:	55                   	push   %ebp
     4e1:	57                   	push   %edi
     4e2:	56                   	push   %esi
     4e3:	53                   	push   %ebx
     4e4:	83 ec 1c             	sub    $0x1c,%esp
     4e7:	8b 6c 24 30          	mov    0x30(%esp),%ebp
     4eb:	8b 74 24 34          	mov    0x34(%esp),%esi
     4ef:	8b 7c 24 38          	mov    0x38(%esp),%edi
  char *s;
  int ret;
  
  s = *ps;
     4f3:	8b 5d 00             	mov    0x0(%ebp),%ebx
  while(s < es && strchr(whitespace, *s))
     4f6:	39 f3                	cmp    %esi,%ebx
     4f8:	72 0d                	jb     507 <gettoken+0x27>
     4fa:	eb 22                	jmp    51e <gettoken+0x3e>
     4fc:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
    s++;
     500:	83 c3 01             	add    $0x1,%ebx
{
  char *s;
  int ret;
  
  s = *ps;
  while(s < es && strchr(whitespace, *s))
     503:	39 f3                	cmp    %esi,%ebx
     505:	74 17                	je     51e <gettoken+0x3e>
     507:	0f be 03             	movsbl (%ebx),%eax
     50a:	c7 04 24 58 19 00 00 	movl   $0x1958,(%esp)
     511:	89 44 24 04          	mov    %eax,0x4(%esp)
     515:	e8 a6 07 00 00       	call   cc0 <strchr>
     51a:	85 c0                	test   %eax,%eax
     51c:	75 e2                	jne    500 <gettoken+0x20>
    s++;
  if(q)
     51e:	85 ff                	test   %edi,%edi
     520:	74 02                	je     524 <gettoken+0x44>
    *q = s;
     522:	89 1f                	mov    %ebx,(%edi)
  ret = *s;
     524:	0f b6 13             	movzbl (%ebx),%edx
     527:	0f be fa             	movsbl %dl,%edi
  switch(*s){
     52a:	80 fa 3c             	cmp    $0x3c,%dl
  s = *ps;
  while(s < es && strchr(whitespace, *s))
    s++;
  if(q)
    *q = s;
  ret = *s;
     52d:	89 f8                	mov    %edi,%eax
  switch(*s){
     52f:	7f 57                	jg     588 <gettoken+0xa8>
     531:	80 fa 3b             	cmp    $0x3b,%dl
     534:	0f 8c a6 00 00 00    	jl     5e0 <gettoken+0x100>
  case '&':
  case '<':
    s++;
    break;
  case '>':
    s++;
     53a:	83 c3 01             	add    $0x1,%ebx
    ret = 'a';
    while(s < es && !strchr(whitespace, *s) && !strchr(symbols, *s))
      s++;
    break;
  }
  if(eq)
     53d:	8b 44 24 3c          	mov    0x3c(%esp),%eax
     541:	85 c0                	test   %eax,%eax
     543:	74 06                	je     54b <gettoken+0x6b>
    *eq = s;
     545:	8b 44 24 3c          	mov    0x3c(%esp),%eax
     549:	89 18                	mov    %ebx,(%eax)
  
  while(s < es && strchr(whitespace, *s))
     54b:	39 f3                	cmp    %esi,%ebx
     54d:	72 10                	jb     55f <gettoken+0x7f>
     54f:	eb 25                	jmp    576 <gettoken+0x96>
     551:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
    s++;
     558:	83 c3 01             	add    $0x1,%ebx
    break;
  }
  if(eq)
    *eq = s;
  
  while(s < es && strchr(whitespace, *s))
     55b:	39 f3                	cmp    %esi,%ebx
     55d:	74 17                	je     576 <gettoken+0x96>
     55f:	0f be 03             	movsbl (%ebx),%eax
     562:	c7 04 24 58 19 00 00 	movl   $0x1958,(%esp)
     569:	89 44 24 04          	mov    %eax,0x4(%esp)
     56d:	e8 4e 07 00 00       	call   cc0 <strchr>
     572:	85 c0                	test   %eax,%eax
     574:	75 e2                	jne    558 <gettoken+0x78>
    s++;
  *ps = s;
     576:	89 5d 00             	mov    %ebx,0x0(%ebp)
  return ret;
}
     579:	83 c4 1c             	add    $0x1c,%esp
     57c:	89 f8                	mov    %edi,%eax
     57e:	5b                   	pop    %ebx
     57f:	5e                   	pop    %esi
     580:	5f                   	pop    %edi
     581:	5d                   	pop    %ebp
     582:	c3                   	ret    
     583:	90                   	nop
     584:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  while(s < es && strchr(whitespace, *s))
    s++;
  if(q)
    *q = s;
  ret = *s;
  switch(*s){
     588:	80 fa 3e             	cmp    $0x3e,%dl
     58b:	74 7b                	je     608 <gettoken+0x128>
     58d:	80 fa 7c             	cmp    $0x7c,%dl
     590:	74 a8                	je     53a <gettoken+0x5a>
      s++;
    }
    break;
  default:
    ret = 'a';
    while(s < es && !strchr(whitespace, *s) && !strchr(symbols, *s))
     592:	39 de                	cmp    %ebx,%esi
      ret = '+';
      s++;
    }
    break;
  default:
    ret = 'a';
     594:	bf 61 00 00 00       	mov    $0x61,%edi
    while(s < es && !strchr(whitespace, *s) && !strchr(symbols, *s))
     599:	77 26                	ja     5c1 <gettoken+0xe1>
     59b:	eb a0                	jmp    53d <gettoken+0x5d>
     59d:	8d 76 00             	lea    0x0(%esi),%esi
     5a0:	0f be 03             	movsbl (%ebx),%eax
     5a3:	c7 04 24 50 19 00 00 	movl   $0x1950,(%esp)
     5aa:	89 44 24 04          	mov    %eax,0x4(%esp)
     5ae:	e8 0d 07 00 00       	call   cc0 <strchr>
     5b3:	85 c0                	test   %eax,%eax
     5b5:	75 1e                	jne    5d5 <gettoken+0xf5>
      s++;
     5b7:	83 c3 01             	add    $0x1,%ebx
      s++;
    }
    break;
  default:
    ret = 'a';
    while(s < es && !strchr(whitespace, *s) && !strchr(symbols, *s))
     5ba:	39 f3                	cmp    %esi,%ebx
     5bc:	74 17                	je     5d5 <gettoken+0xf5>
     5be:	0f be 03             	movsbl (%ebx),%eax
     5c1:	89 44 24 04          	mov    %eax,0x4(%esp)
     5c5:	c7 04 24 58 19 00 00 	movl   $0x1958,(%esp)
     5cc:	e8 ef 06 00 00       	call   cc0 <strchr>
     5d1:	85 c0                	test   %eax,%eax
     5d3:	74 cb                	je     5a0 <gettoken+0xc0>
      ret = '+';
      s++;
    }
    break;
  default:
    ret = 'a';
     5d5:	bf 61 00 00 00       	mov    $0x61,%edi
     5da:	e9 5e ff ff ff       	jmp    53d <gettoken+0x5d>
     5df:	90                   	nop
  while(s < es && strchr(whitespace, *s))
    s++;
  if(q)
    *q = s;
  ret = *s;
  switch(*s){
     5e0:	80 fa 29             	cmp    $0x29,%dl
     5e3:	7f ad                	jg     592 <gettoken+0xb2>
     5e5:	80 fa 28             	cmp    $0x28,%dl
     5e8:	0f 8d 4c ff ff ff    	jge    53a <gettoken+0x5a>
     5ee:	84 d2                	test   %dl,%dl
     5f0:	0f 84 47 ff ff ff    	je     53d <gettoken+0x5d>
     5f6:	80 fa 26             	cmp    $0x26,%dl
     5f9:	75 97                	jne    592 <gettoken+0xb2>
     5fb:	90                   	nop
     5fc:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
     600:	e9 35 ff ff ff       	jmp    53a <gettoken+0x5a>
     605:	8d 76 00             	lea    0x0(%esi),%esi
  case '<':
    s++;
    break;
  case '>':
    s++;
    if(*s == '>'){
     608:	80 7b 01 3e          	cmpb   $0x3e,0x1(%ebx)
     60c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
     610:	0f 85 24 ff ff ff    	jne    53a <gettoken+0x5a>
      ret = '+';
      s++;
     616:	83 c3 02             	add    $0x2,%ebx
    s++;
    break;
  case '>':
    s++;
    if(*s == '>'){
      ret = '+';
     619:	bf 2b 00 00 00       	mov    $0x2b,%edi
     61e:	e9 1a ff ff ff       	jmp    53d <gettoken+0x5d>
     623:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
     629:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00000630 <peek>:
  return ret;
}

int
peek(char **ps, char *es, char *toks)
{
     630:	57                   	push   %edi
     631:	56                   	push   %esi
     632:	53                   	push   %ebx
     633:	83 ec 10             	sub    $0x10,%esp
     636:	8b 7c 24 20          	mov    0x20(%esp),%edi
     63a:	8b 74 24 24          	mov    0x24(%esp),%esi
  char *s;
  
  s = *ps;
     63e:	8b 1f                	mov    (%edi),%ebx
  while(s < es && strchr(whitespace, *s))
     640:	39 f3                	cmp    %esi,%ebx
     642:	72 0b                	jb     64f <peek+0x1f>
     644:	eb 20                	jmp    666 <peek+0x36>
     646:	66 90                	xchg   %ax,%ax
    s++;
     648:	83 c3 01             	add    $0x1,%ebx
peek(char **ps, char *es, char *toks)
{
  char *s;
  
  s = *ps;
  while(s < es && strchr(whitespace, *s))
     64b:	39 f3                	cmp    %esi,%ebx
     64d:	74 17                	je     666 <peek+0x36>
     64f:	0f be 03             	movsbl (%ebx),%eax
     652:	c7 04 24 58 19 00 00 	movl   $0x1958,(%esp)
     659:	89 44 24 04          	mov    %eax,0x4(%esp)
     65d:	e8 5e 06 00 00       	call   cc0 <strchr>
     662:	85 c0                	test   %eax,%eax
     664:	75 e2                	jne    648 <peek+0x18>
    s++;
  *ps = s;
     666:	89 1f                	mov    %ebx,(%edi)
  return *s && strchr(toks, *s);
     668:	0f b6 13             	movzbl (%ebx),%edx
     66b:	31 c0                	xor    %eax,%eax
     66d:	84 d2                	test   %dl,%dl
     66f:	75 07                	jne    678 <peek+0x48>
}
     671:	83 c4 10             	add    $0x10,%esp
     674:	5b                   	pop    %ebx
     675:	5e                   	pop    %esi
     676:	5f                   	pop    %edi
     677:	c3                   	ret    
  
  s = *ps;
  while(s < es && strchr(whitespace, *s))
    s++;
  *ps = s;
  return *s && strchr(toks, *s);
     678:	8b 44 24 28          	mov    0x28(%esp),%eax
     67c:	0f be d2             	movsbl %dl,%edx
     67f:	89 54 24 04          	mov    %edx,0x4(%esp)
     683:	89 04 24             	mov    %eax,(%esp)
     686:	e8 35 06 00 00       	call   cc0 <strchr>
  *ps = s;
  return ret;
}

int
peek(char **ps, char *es, char *toks)
     68b:	85 c0                	test   %eax,%eax
  
  s = *ps;
  while(s < es && strchr(whitespace, *s))
    s++;
  *ps = s;
  return *s && strchr(toks, *s);
     68d:	0f 95 c0             	setne  %al
}
     690:	83 c4 10             	add    $0x10,%esp
     693:	5b                   	pop    %ebx
  
  s = *ps;
  while(s < es && strchr(whitespace, *s))
    s++;
  *ps = s;
  return *s && strchr(toks, *s);
     694:	0f b6 c0             	movzbl %al,%eax
}
     697:	5e                   	pop    %esi
     698:	5f                   	pop    %edi
     699:	c3                   	ret    
     69a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi

000006a0 <parseredirs>:
  return cmd;
}

struct cmd*
parseredirs(struct cmd *cmd, char **ps, char *es)
{
     6a0:	55                   	push   %ebp
     6a1:	57                   	push   %edi
     6a2:	56                   	push   %esi
     6a3:	53                   	push   %ebx
     6a4:	83 ec 3c             	sub    $0x3c,%esp
     6a7:	8b 6c 24 50          	mov    0x50(%esp),%ebp
     6ab:	8b 7c 24 54          	mov    0x54(%esp),%edi
     6af:	8b 74 24 58          	mov    0x58(%esp),%esi
     6b3:	90                   	nop
     6b4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  int tok;
  char *q, *eq;

  while(peek(ps, es, "<>")){
     6b8:	c7 44 24 08 c9 12 00 	movl   $0x12c9,0x8(%esp)
     6bf:	00 
     6c0:	89 74 24 04          	mov    %esi,0x4(%esp)
     6c4:	89 3c 24             	mov    %edi,(%esp)
     6c7:	e8 64 ff ff ff       	call   630 <peek>
     6cc:	85 c0                	test   %eax,%eax
     6ce:	0f 84 9c 00 00 00    	je     770 <parseredirs+0xd0>
    tok = gettoken(ps, es, 0, 0);
     6d4:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
     6db:	00 
     6dc:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
     6e3:	00 
     6e4:	89 74 24 04          	mov    %esi,0x4(%esp)
     6e8:	89 3c 24             	mov    %edi,(%esp)
     6eb:	e8 f0 fd ff ff       	call   4e0 <gettoken>
    if(gettoken(ps, es, &q, &eq) != 'a')
     6f0:	89 74 24 04          	mov    %esi,0x4(%esp)
     6f4:	89 3c 24             	mov    %edi,(%esp)
{
  int tok;
  char *q, *eq;

  while(peek(ps, es, "<>")){
    tok = gettoken(ps, es, 0, 0);
     6f7:	89 c3                	mov    %eax,%ebx
    if(gettoken(ps, es, &q, &eq) != 'a')
     6f9:	8d 44 24 2c          	lea    0x2c(%esp),%eax
     6fd:	89 44 24 0c          	mov    %eax,0xc(%esp)
     701:	8d 44 24 28          	lea    0x28(%esp),%eax
     705:	89 44 24 08          	mov    %eax,0x8(%esp)
     709:	e8 d2 fd ff ff       	call   4e0 <gettoken>
     70e:	83 f8 61             	cmp    $0x61,%eax
     711:	75 67                	jne    77a <parseredirs+0xda>
      panic("missing file for redirection");
    switch(tok){
     713:	83 fb 3c             	cmp    $0x3c,%ebx
     716:	74 40                	je     758 <parseredirs+0xb8>
     718:	83 fb 3e             	cmp    $0x3e,%ebx
     71b:	74 05                	je     722 <parseredirs+0x82>
     71d:	83 fb 2b             	cmp    $0x2b,%ebx
     720:	75 96                	jne    6b8 <parseredirs+0x18>
      break;
    case '>':
      cmd = redircmd(cmd, q, eq, O_WRONLY|O_CREATE, 1);
      break;
    case '+':  // >>
      cmd = redircmd(cmd, q, eq, O_WRONLY|O_CREATE, 1);
     722:	c7 44 24 10 01 00 00 	movl   $0x1,0x10(%esp)
     729:	00 
     72a:	c7 44 24 0c 01 02 00 	movl   $0x201,0xc(%esp)
     731:	00 
     732:	8b 44 24 2c          	mov    0x2c(%esp),%eax
     736:	89 2c 24             	mov    %ebp,(%esp)
     739:	89 44 24 08          	mov    %eax,0x8(%esp)
     73d:	8b 44 24 28          	mov    0x28(%esp),%eax
     741:	89 44 24 04          	mov    %eax,0x4(%esp)
     745:	e8 56 fc ff ff       	call   3a0 <redircmd>
     74a:	89 c5                	mov    %eax,%ebp
      break;
     74c:	e9 67 ff ff ff       	jmp    6b8 <parseredirs+0x18>
     751:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
    tok = gettoken(ps, es, 0, 0);
    if(gettoken(ps, es, &q, &eq) != 'a')
      panic("missing file for redirection");
    switch(tok){
    case '<':
      cmd = redircmd(cmd, q, eq, O_RDONLY, 0);
     758:	c7 44 24 10 00 00 00 	movl   $0x0,0x10(%esp)
     75f:	00 
     760:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
     767:	00 
     768:	eb c8                	jmp    732 <parseredirs+0x92>
     76a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
      cmd = redircmd(cmd, q, eq, O_WRONLY|O_CREATE, 1);
      break;
    }
  }
  return cmd;
}
     770:	83 c4 3c             	add    $0x3c,%esp
     773:	89 e8                	mov    %ebp,%eax
     775:	5b                   	pop    %ebx
     776:	5e                   	pop    %esi
     777:	5f                   	pop    %edi
     778:	5d                   	pop    %ebp
     779:	c3                   	ret    
  char *q, *eq;

  while(peek(ps, es, "<>")){
    tok = gettoken(ps, es, 0, 0);
    if(gettoken(ps, es, &q, &eq) != 'a')
      panic("missing file for redirection");
     77a:	c7 04 24 ac 12 00 00 	movl   $0x12ac,(%esp)
     781:	e8 da f9 ff ff       	call   160 <panic>
     786:	8d 76 00             	lea    0x0(%esi),%esi
     789:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00000790 <parseexec>:
  return cmd;
}

struct cmd*
parseexec(char **ps, char *es)
{
     790:	55                   	push   %ebp
     791:	57                   	push   %edi
     792:	56                   	push   %esi
     793:	53                   	push   %ebx
     794:	83 ec 3c             	sub    $0x3c,%esp
     797:	8b 74 24 50          	mov    0x50(%esp),%esi
     79b:	8b 7c 24 54          	mov    0x54(%esp),%edi
  char *q, *eq;
  int tok, argc;
  struct execcmd *cmd;
  struct cmd *ret;
  
  if(peek(ps, es, "("))
     79f:	c7 44 24 08 cc 12 00 	movl   $0x12cc,0x8(%esp)
     7a6:	00 
     7a7:	89 34 24             	mov    %esi,(%esp)
     7aa:	89 7c 24 04          	mov    %edi,0x4(%esp)
     7ae:	e8 7d fe ff ff       	call   630 <peek>
     7b3:	85 c0                	test   %eax,%eax
     7b5:	0f 85 a5 00 00 00    	jne    860 <parseexec+0xd0>
    return parseblock(ps, es);

  ret = execcmd();
     7bb:	e8 a0 fb ff ff       	call   360 <execcmd>
  cmd = (struct execcmd*)ret;

  argc = 0;
     7c0:	31 ed                	xor    %ebp,%ebp
  ret = parseredirs(ret, ps, es);
     7c2:	89 7c 24 08          	mov    %edi,0x8(%esp)
     7c6:	89 74 24 04          	mov    %esi,0x4(%esp)
  struct cmd *ret;
  
  if(peek(ps, es, "("))
    return parseblock(ps, es);

  ret = execcmd();
     7ca:	89 44 24 1c          	mov    %eax,0x1c(%esp)
  cmd = (struct execcmd*)ret;

  argc = 0;
  ret = parseredirs(ret, ps, es);
     7ce:	89 04 24             	mov    %eax,(%esp)
     7d1:	e8 ca fe ff ff       	call   6a0 <parseredirs>
     7d6:	8b 5c 24 1c          	mov    0x1c(%esp),%ebx
     7da:	89 44 24 18          	mov    %eax,0x18(%esp)
  while(!peek(ps, es, "|)&;")){
     7de:	eb 18                	jmp    7f8 <parseexec+0x68>
    cmd->argv[argc] = q;
    cmd->eargv[argc] = eq;
    argc++;
    if(argc >= MAXARGS)
      panic("too many args");
    ret = parseredirs(ret, ps, es);
     7e0:	8b 44 24 18          	mov    0x18(%esp),%eax
     7e4:	89 7c 24 08          	mov    %edi,0x8(%esp)
     7e8:	89 74 24 04          	mov    %esi,0x4(%esp)
     7ec:	89 04 24             	mov    %eax,(%esp)
     7ef:	e8 ac fe ff ff       	call   6a0 <parseredirs>
     7f4:	89 44 24 18          	mov    %eax,0x18(%esp)
  ret = execcmd();
  cmd = (struct execcmd*)ret;

  argc = 0;
  ret = parseredirs(ret, ps, es);
  while(!peek(ps, es, "|)&;")){
     7f8:	c7 44 24 08 e3 12 00 	movl   $0x12e3,0x8(%esp)
     7ff:	00 
     800:	89 7c 24 04          	mov    %edi,0x4(%esp)
     804:	89 34 24             	mov    %esi,(%esp)
     807:	e8 24 fe ff ff       	call   630 <peek>
     80c:	85 c0                	test   %eax,%eax
     80e:	75 70                	jne    880 <parseexec+0xf0>
    if((tok=gettoken(ps, es, &q, &eq)) == 0)
     810:	8d 44 24 2c          	lea    0x2c(%esp),%eax
     814:	89 44 24 0c          	mov    %eax,0xc(%esp)
     818:	8d 44 24 28          	lea    0x28(%esp),%eax
     81c:	89 44 24 08          	mov    %eax,0x8(%esp)
     820:	89 7c 24 04          	mov    %edi,0x4(%esp)
     824:	89 34 24             	mov    %esi,(%esp)
     827:	e8 b4 fc ff ff       	call   4e0 <gettoken>
     82c:	85 c0                	test   %eax,%eax
     82e:	74 50                	je     880 <parseexec+0xf0>
      break;
    if(tok != 'a')
     830:	83 f8 61             	cmp    $0x61,%eax
     833:	75 6b                	jne    8a0 <parseexec+0x110>
      panic("syntax");
    cmd->argv[argc] = q;
     835:	8b 44 24 28          	mov    0x28(%esp),%eax
    cmd->eargv[argc] = eq;
    argc++;
     839:	83 c5 01             	add    $0x1,%ebp
  while(!peek(ps, es, "|)&;")){
    if((tok=gettoken(ps, es, &q, &eq)) == 0)
      break;
    if(tok != 'a')
      panic("syntax");
    cmd->argv[argc] = q;
     83c:	89 43 04             	mov    %eax,0x4(%ebx)
    cmd->eargv[argc] = eq;
     83f:	8b 44 24 2c          	mov    0x2c(%esp),%eax
     843:	89 43 2c             	mov    %eax,0x2c(%ebx)
    argc++;
     846:	83 c3 04             	add    $0x4,%ebx
    if(argc >= MAXARGS)
     849:	83 fd 0a             	cmp    $0xa,%ebp
     84c:	75 92                	jne    7e0 <parseexec+0x50>
      panic("too many args");
     84e:	c7 04 24 d5 12 00 00 	movl   $0x12d5,(%esp)
     855:	e8 06 f9 ff ff       	call   160 <panic>
     85a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  int tok, argc;
  struct execcmd *cmd;
  struct cmd *ret;
  
  if(peek(ps, es, "("))
    return parseblock(ps, es);
     860:	89 7c 24 04          	mov    %edi,0x4(%esp)
     864:	89 34 24             	mov    %esi,(%esp)
     867:	e8 a4 01 00 00       	call   a10 <parseblock>
     86c:	89 44 24 18          	mov    %eax,0x18(%esp)
    ret = parseredirs(ret, ps, es);
  }
  cmd->argv[argc] = 0;
  cmd->eargv[argc] = 0;
  return ret;
}
     870:	8b 44 24 18          	mov    0x18(%esp),%eax
     874:	83 c4 3c             	add    $0x3c,%esp
     877:	5b                   	pop    %ebx
     878:	5e                   	pop    %esi
     879:	5f                   	pop    %edi
     87a:	5d                   	pop    %ebp
     87b:	c3                   	ret    
     87c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
    argc++;
    if(argc >= MAXARGS)
      panic("too many args");
    ret = parseredirs(ret, ps, es);
  }
  cmd->argv[argc] = 0;
     880:	8b 44 24 1c          	mov    0x1c(%esp),%eax
     884:	c7 44 a8 04 00 00 00 	movl   $0x0,0x4(%eax,%ebp,4)
     88b:	00 
  cmd->eargv[argc] = 0;
     88c:	c7 44 a8 2c 00 00 00 	movl   $0x0,0x2c(%eax,%ebp,4)
     893:	00 
  return ret;
}
     894:	8b 44 24 18          	mov    0x18(%esp),%eax
     898:	83 c4 3c             	add    $0x3c,%esp
     89b:	5b                   	pop    %ebx
     89c:	5e                   	pop    %esi
     89d:	5f                   	pop    %edi
     89e:	5d                   	pop    %ebp
     89f:	c3                   	ret    
  ret = parseredirs(ret, ps, es);
  while(!peek(ps, es, "|)&;")){
    if((tok=gettoken(ps, es, &q, &eq)) == 0)
      break;
    if(tok != 'a')
      panic("syntax");
     8a0:	c7 04 24 ce 12 00 00 	movl   $0x12ce,(%esp)
     8a7:	e8 b4 f8 ff ff       	call   160 <panic>
     8ac:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi

000008b0 <parsepipe>:
  return cmd;
}

struct cmd*
parsepipe(char **ps, char *es)
{
     8b0:	83 ec 1c             	sub    $0x1c,%esp
     8b3:	89 5c 24 10          	mov    %ebx,0x10(%esp)
     8b7:	8b 5c 24 20          	mov    0x20(%esp),%ebx
     8bb:	89 74 24 14          	mov    %esi,0x14(%esp)
     8bf:	8b 74 24 24          	mov    0x24(%esp),%esi
     8c3:	89 7c 24 18          	mov    %edi,0x18(%esp)
  struct cmd *cmd;
  
  cmd = parseexec(ps, es);
     8c7:	89 1c 24             	mov    %ebx,(%esp)
     8ca:	89 74 24 04          	mov    %esi,0x4(%esp)
     8ce:	e8 bd fe ff ff       	call   790 <parseexec>
  if(peek(ps, es, "|")){
     8d3:	c7 44 24 08 e8 12 00 	movl   $0x12e8,0x8(%esp)
     8da:	00 
     8db:	89 74 24 04          	mov    %esi,0x4(%esp)
     8df:	89 1c 24             	mov    %ebx,(%esp)
struct cmd*
parsepipe(char **ps, char *es)
{
  struct cmd *cmd;
  
  cmd = parseexec(ps, es);
     8e2:	89 c7                	mov    %eax,%edi
  if(peek(ps, es, "|")){
     8e4:	e8 47 fd ff ff       	call   630 <peek>
     8e9:	85 c0                	test   %eax,%eax
     8eb:	75 13                	jne    900 <parsepipe+0x50>
    gettoken(ps, es, 0, 0);
    cmd = pipecmd(cmd, parsepipe(ps, es));
  }
  return cmd;
}
     8ed:	89 f8                	mov    %edi,%eax
     8ef:	8b 5c 24 10          	mov    0x10(%esp),%ebx
     8f3:	8b 74 24 14          	mov    0x14(%esp),%esi
     8f7:	8b 7c 24 18          	mov    0x18(%esp),%edi
     8fb:	83 c4 1c             	add    $0x1c,%esp
     8fe:	c3                   	ret    
     8ff:	90                   	nop
{
  struct cmd *cmd;
  
  cmd = parseexec(ps, es);
  if(peek(ps, es, "|")){
    gettoken(ps, es, 0, 0);
     900:	89 74 24 04          	mov    %esi,0x4(%esp)
     904:	89 1c 24             	mov    %ebx,(%esp)
     907:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
     90e:	00 
     90f:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
     916:	00 
     917:	e8 c4 fb ff ff       	call   4e0 <gettoken>
    cmd = pipecmd(cmd, parsepipe(ps, es));
     91c:	89 74 24 04          	mov    %esi,0x4(%esp)
     920:	89 1c 24             	mov    %ebx,(%esp)
     923:	e8 88 ff ff ff       	call   8b0 <parsepipe>
  }
  return cmd;
}
     928:	8b 5c 24 10          	mov    0x10(%esp),%ebx
  struct cmd *cmd;
  
  cmd = parseexec(ps, es);
  if(peek(ps, es, "|")){
    gettoken(ps, es, 0, 0);
    cmd = pipecmd(cmd, parsepipe(ps, es));
     92c:	89 7c 24 20          	mov    %edi,0x20(%esp)
  }
  return cmd;
}
     930:	8b 74 24 14          	mov    0x14(%esp),%esi
     934:	8b 7c 24 18          	mov    0x18(%esp),%edi
  struct cmd *cmd;
  
  cmd = parseexec(ps, es);
  if(peek(ps, es, "|")){
    gettoken(ps, es, 0, 0);
    cmd = pipecmd(cmd, parsepipe(ps, es));
     938:	89 44 24 24          	mov    %eax,0x24(%esp)
  }
  return cmd;
}
     93c:	83 c4 1c             	add    $0x1c,%esp
  struct cmd *cmd;
  
  cmd = parseexec(ps, es);
  if(peek(ps, es, "|")){
    gettoken(ps, es, 0, 0);
    cmd = pipecmd(cmd, parsepipe(ps, es));
     93f:	e9 bc fa ff ff       	jmp    400 <pipecmd>
     944:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
     94a:	8d bf 00 00 00 00    	lea    0x0(%edi),%edi

00000950 <parseline>:
  return cmd;
}

struct cmd*
parseline(char **ps, char *es)
{
     950:	57                   	push   %edi
     951:	56                   	push   %esi
     952:	53                   	push   %ebx
     953:	83 ec 10             	sub    $0x10,%esp
     956:	8b 5c 24 20          	mov    0x20(%esp),%ebx
     95a:	8b 74 24 24          	mov    0x24(%esp),%esi
  struct cmd *cmd;

  cmd = parsepipe(ps, es);
     95e:	89 1c 24             	mov    %ebx,(%esp)
     961:	89 74 24 04          	mov    %esi,0x4(%esp)
     965:	e8 46 ff ff ff       	call   8b0 <parsepipe>
     96a:	89 c7                	mov    %eax,%edi
  while(peek(ps, es, "&")){
     96c:	eb 28                	jmp    996 <parseline+0x46>
     96e:	66 90                	xchg   %ax,%ax
    gettoken(ps, es, 0, 0);
     970:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
     977:	00 
     978:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
     97f:	00 
     980:	89 74 24 04          	mov    %esi,0x4(%esp)
     984:	89 1c 24             	mov    %ebx,(%esp)
     987:	e8 54 fb ff ff       	call   4e0 <gettoken>
    cmd = backcmd(cmd);
     98c:	89 3c 24             	mov    %edi,(%esp)
     98f:	e8 0c fb ff ff       	call   4a0 <backcmd>
     994:	89 c7                	mov    %eax,%edi
parseline(char **ps, char *es)
{
  struct cmd *cmd;

  cmd = parsepipe(ps, es);
  while(peek(ps, es, "&")){
     996:	c7 44 24 08 ea 12 00 	movl   $0x12ea,0x8(%esp)
     99d:	00 
     99e:	89 74 24 04          	mov    %esi,0x4(%esp)
     9a2:	89 1c 24             	mov    %ebx,(%esp)
     9a5:	e8 86 fc ff ff       	call   630 <peek>
     9aa:	85 c0                	test   %eax,%eax
     9ac:	75 c2                	jne    970 <parseline+0x20>
    gettoken(ps, es, 0, 0);
    cmd = backcmd(cmd);
  }
  if(peek(ps, es, ";")){
     9ae:	c7 44 24 08 e6 12 00 	movl   $0x12e6,0x8(%esp)
     9b5:	00 
     9b6:	89 74 24 04          	mov    %esi,0x4(%esp)
     9ba:	89 1c 24             	mov    %ebx,(%esp)
     9bd:	e8 6e fc ff ff       	call   630 <peek>
     9c2:	85 c0                	test   %eax,%eax
     9c4:	75 0a                	jne    9d0 <parseline+0x80>
    gettoken(ps, es, 0, 0);
    cmd = listcmd(cmd, parseline(ps, es));
  }
  return cmd;
}
     9c6:	83 c4 10             	add    $0x10,%esp
     9c9:	89 f8                	mov    %edi,%eax
     9cb:	5b                   	pop    %ebx
     9cc:	5e                   	pop    %esi
     9cd:	5f                   	pop    %edi
     9ce:	c3                   	ret    
     9cf:	90                   	nop
  while(peek(ps, es, "&")){
    gettoken(ps, es, 0, 0);
    cmd = backcmd(cmd);
  }
  if(peek(ps, es, ";")){
    gettoken(ps, es, 0, 0);
     9d0:	89 74 24 04          	mov    %esi,0x4(%esp)
     9d4:	89 1c 24             	mov    %ebx,(%esp)
     9d7:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
     9de:	00 
     9df:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
     9e6:	00 
     9e7:	e8 f4 fa ff ff       	call   4e0 <gettoken>
    cmd = listcmd(cmd, parseline(ps, es));
     9ec:	89 74 24 04          	mov    %esi,0x4(%esp)
     9f0:	89 1c 24             	mov    %ebx,(%esp)
     9f3:	e8 58 ff ff ff       	call   950 <parseline>
     9f8:	89 7c 24 20          	mov    %edi,0x20(%esp)
     9fc:	89 44 24 24          	mov    %eax,0x24(%esp)
  }
  return cmd;
}
     a00:	83 c4 10             	add    $0x10,%esp
     a03:	5b                   	pop    %ebx
     a04:	5e                   	pop    %esi
     a05:	5f                   	pop    %edi
    gettoken(ps, es, 0, 0);
    cmd = backcmd(cmd);
  }
  if(peek(ps, es, ";")){
    gettoken(ps, es, 0, 0);
    cmd = listcmd(cmd, parseline(ps, es));
     a06:	e9 45 fa ff ff       	jmp    450 <listcmd>
     a0b:	90                   	nop
     a0c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi

00000a10 <parseblock>:
  return cmd;
}

struct cmd*
parseblock(char **ps, char *es)
{
     a10:	83 ec 1c             	sub    $0x1c,%esp
     a13:	89 5c 24 10          	mov    %ebx,0x10(%esp)
     a17:	8b 5c 24 20          	mov    0x20(%esp),%ebx
     a1b:	89 74 24 14          	mov    %esi,0x14(%esp)
     a1f:	8b 74 24 24          	mov    0x24(%esp),%esi
     a23:	89 7c 24 18          	mov    %edi,0x18(%esp)
  struct cmd *cmd;

  if(!peek(ps, es, "("))
     a27:	c7 44 24 08 cc 12 00 	movl   $0x12cc,0x8(%esp)
     a2e:	00 
     a2f:	89 1c 24             	mov    %ebx,(%esp)
     a32:	89 74 24 04          	mov    %esi,0x4(%esp)
     a36:	e8 f5 fb ff ff       	call   630 <peek>
     a3b:	85 c0                	test   %eax,%eax
     a3d:	74 7e                	je     abd <parseblock+0xad>
    panic("parseblock");
  gettoken(ps, es, 0, 0);
     a3f:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
     a46:	00 
     a47:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
     a4e:	00 
     a4f:	89 74 24 04          	mov    %esi,0x4(%esp)
     a53:	89 1c 24             	mov    %ebx,(%esp)
     a56:	e8 85 fa ff ff       	call   4e0 <gettoken>
  cmd = parseline(ps, es);
     a5b:	89 74 24 04          	mov    %esi,0x4(%esp)
     a5f:	89 1c 24             	mov    %ebx,(%esp)
     a62:	e8 e9 fe ff ff       	call   950 <parseline>
  if(!peek(ps, es, ")"))
     a67:	c7 44 24 08 08 13 00 	movl   $0x1308,0x8(%esp)
     a6e:	00 
     a6f:	89 74 24 04          	mov    %esi,0x4(%esp)
     a73:	89 1c 24             	mov    %ebx,(%esp)
  struct cmd *cmd;

  if(!peek(ps, es, "("))
    panic("parseblock");
  gettoken(ps, es, 0, 0);
  cmd = parseline(ps, es);
     a76:	89 c7                	mov    %eax,%edi
  if(!peek(ps, es, ")"))
     a78:	e8 b3 fb ff ff       	call   630 <peek>
     a7d:	85 c0                	test   %eax,%eax
     a7f:	74 48                	je     ac9 <parseblock+0xb9>
    panic("syntax - missing )");
  gettoken(ps, es, 0, 0);
     a81:	89 74 24 04          	mov    %esi,0x4(%esp)
     a85:	89 1c 24             	mov    %ebx,(%esp)
     a88:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
     a8f:	00 
     a90:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
     a97:	00 
     a98:	e8 43 fa ff ff       	call   4e0 <gettoken>
  cmd = parseredirs(cmd, ps, es);
     a9d:	89 74 24 08          	mov    %esi,0x8(%esp)
     aa1:	89 5c 24 04          	mov    %ebx,0x4(%esp)
     aa5:	89 3c 24             	mov    %edi,(%esp)
     aa8:	e8 f3 fb ff ff       	call   6a0 <parseredirs>
  return cmd;
}
     aad:	8b 5c 24 10          	mov    0x10(%esp),%ebx
     ab1:	8b 74 24 14          	mov    0x14(%esp),%esi
     ab5:	8b 7c 24 18          	mov    0x18(%esp),%edi
     ab9:	83 c4 1c             	add    $0x1c,%esp
     abc:	c3                   	ret    
parseblock(char **ps, char *es)
{
  struct cmd *cmd;

  if(!peek(ps, es, "("))
    panic("parseblock");
     abd:	c7 04 24 ec 12 00 00 	movl   $0x12ec,(%esp)
     ac4:	e8 97 f6 ff ff       	call   160 <panic>
  gettoken(ps, es, 0, 0);
  cmd = parseline(ps, es);
  if(!peek(ps, es, ")"))
    panic("syntax - missing )");
     ac9:	c7 04 24 f7 12 00 00 	movl   $0x12f7,(%esp)
     ad0:	e8 8b f6 ff ff       	call   160 <panic>
     ad5:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
     ad9:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00000ae0 <nulterminate>:
}

// NUL-terminate all the counted strings.
struct cmd*
nulterminate(struct cmd *cmd)
{
     ae0:	53                   	push   %ebx
     ae1:	83 ec 18             	sub    $0x18,%esp
     ae4:	8b 5c 24 20          	mov    0x20(%esp),%ebx
  struct execcmd *ecmd;
  struct listcmd *lcmd;
  struct pipecmd *pcmd;
  struct redircmd *rcmd;

  if(cmd == 0)
     ae8:	85 db                	test   %ebx,%ebx
     aea:	74 05                	je     af1 <nulterminate+0x11>
    return 0;
  
  switch(cmd->type){
     aec:	83 3b 05             	cmpl   $0x5,(%ebx)
     aef:	76 07                	jbe    af8 <nulterminate+0x18>
    bcmd = (struct backcmd*)cmd;
    nulterminate(bcmd->cmd);
    break;
  }
  return cmd;
}
     af1:	83 c4 18             	add    $0x18,%esp
     af4:	89 d8                	mov    %ebx,%eax
     af6:	5b                   	pop    %ebx
     af7:	c3                   	ret    
  struct redircmd *rcmd;

  if(cmd == 0)
    return 0;
  
  switch(cmd->type){
     af8:	8b 03                	mov    (%ebx),%eax
     afa:	ff 24 85 48 13 00 00 	jmp    *0x1348(,%eax,4)
     b01:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
    nulterminate(pcmd->right);
    break;
    
  case LIST:
    lcmd = (struct listcmd*)cmd;
    nulterminate(lcmd->left);
     b08:	8b 43 04             	mov    0x4(%ebx),%eax
     b0b:	89 04 24             	mov    %eax,(%esp)
     b0e:	e8 cd ff ff ff       	call   ae0 <nulterminate>
    nulterminate(lcmd->right);
     b13:	8b 43 08             	mov    0x8(%ebx),%eax
     b16:	89 04 24             	mov    %eax,(%esp)
     b19:	e8 c2 ff ff ff       	call   ae0 <nulterminate>
    bcmd = (struct backcmd*)cmd;
    nulterminate(bcmd->cmd);
    break;
  }
  return cmd;
}
     b1e:	83 c4 18             	add    $0x18,%esp
     b21:	89 d8                	mov    %ebx,%eax
     b23:	5b                   	pop    %ebx
     b24:	c3                   	ret    
     b25:	8d 76 00             	lea    0x0(%esi),%esi
    nulterminate(lcmd->right);
    break;

  case BACK:
    bcmd = (struct backcmd*)cmd;
    nulterminate(bcmd->cmd);
     b28:	8b 43 04             	mov    0x4(%ebx),%eax
     b2b:	89 04 24             	mov    %eax,(%esp)
     b2e:	e8 ad ff ff ff       	call   ae0 <nulterminate>
    break;
  }
  return cmd;
}
     b33:	83 c4 18             	add    $0x18,%esp
     b36:	89 d8                	mov    %ebx,%eax
     b38:	5b                   	pop    %ebx
     b39:	c3                   	ret    
     b3a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
      *ecmd->eargv[i] = 0;
    break;

  case REDIR:
    rcmd = (struct redircmd*)cmd;
    nulterminate(rcmd->cmd);
     b40:	8b 43 04             	mov    0x4(%ebx),%eax
     b43:	89 04 24             	mov    %eax,(%esp)
     b46:	e8 95 ff ff ff       	call   ae0 <nulterminate>
    *rcmd->efile = 0;
     b4b:	8b 43 0c             	mov    0xc(%ebx),%eax
     b4e:	c6 00 00             	movb   $0x0,(%eax)
    bcmd = (struct backcmd*)cmd;
    nulterminate(bcmd->cmd);
    break;
  }
  return cmd;
}
     b51:	83 c4 18             	add    $0x18,%esp
     b54:	89 d8                	mov    %ebx,%eax
     b56:	5b                   	pop    %ebx
     b57:	c3                   	ret    
    return 0;
  
  switch(cmd->type){
  case EXEC:
    ecmd = (struct execcmd*)cmd;
    for(i=0; ecmd->argv[i]; i++)
     b58:	8b 4b 04             	mov    0x4(%ebx),%ecx
     b5b:	85 c9                	test   %ecx,%ecx
     b5d:	74 92                	je     af1 <nulterminate+0x11>
     b5f:	89 d8                	mov    %ebx,%eax
     b61:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
      *ecmd->eargv[i] = 0;
     b68:	8b 50 2c             	mov    0x2c(%eax),%edx
     b6b:	83 c0 04             	add    $0x4,%eax
     b6e:	c6 02 00             	movb   $0x0,(%edx)
    return 0;
  
  switch(cmd->type){
  case EXEC:
    ecmd = (struct execcmd*)cmd;
    for(i=0; ecmd->argv[i]; i++)
     b71:	8b 50 04             	mov    0x4(%eax),%edx
     b74:	85 d2                	test   %edx,%edx
     b76:	75 f0                	jne    b68 <nulterminate+0x88>
    bcmd = (struct backcmd*)cmd;
    nulterminate(bcmd->cmd);
    break;
  }
  return cmd;
}
     b78:	83 c4 18             	add    $0x18,%esp
     b7b:	89 d8                	mov    %ebx,%eax
     b7d:	5b                   	pop    %ebx
     b7e:	c3                   	ret    
     b7f:	90                   	nop

00000b80 <parsecmd>:
struct cmd *parseexec(char**, char*);
struct cmd *nulterminate(struct cmd*);

struct cmd*
parsecmd(char *s)
{
     b80:	56                   	push   %esi
     b81:	53                   	push   %ebx
     b82:	83 ec 14             	sub    $0x14,%esp
  char *es;
  struct cmd *cmd;
  
  es = s + strlen(s);
     b85:	8b 5c 24 20          	mov    0x20(%esp),%ebx
     b89:	89 1c 24             	mov    %ebx,(%esp)
     b8c:	e8 ef 00 00 00       	call   c80 <strlen>
     b91:	01 c3                	add    %eax,%ebx
  cmd = parseline(&s, es);
     b93:	8d 44 24 20          	lea    0x20(%esp),%eax
     b97:	89 5c 24 04          	mov    %ebx,0x4(%esp)
     b9b:	89 04 24             	mov    %eax,(%esp)
     b9e:	e8 ad fd ff ff       	call   950 <parseline>
  peek(&s, es, "");
     ba3:	c7 44 24 08 96 12 00 	movl   $0x1296,0x8(%esp)
     baa:	00 
     bab:	89 5c 24 04          	mov    %ebx,0x4(%esp)
{
  char *es;
  struct cmd *cmd;
  
  es = s + strlen(s);
  cmd = parseline(&s, es);
     baf:	89 c6                	mov    %eax,%esi
  peek(&s, es, "");
     bb1:	8d 44 24 20          	lea    0x20(%esp),%eax
     bb5:	89 04 24             	mov    %eax,(%esp)
     bb8:	e8 73 fa ff ff       	call   630 <peek>
  if(s != es){
     bbd:	8b 44 24 20          	mov    0x20(%esp),%eax
     bc1:	39 d8                	cmp    %ebx,%eax
     bc3:	75 10                	jne    bd5 <parsecmd+0x55>
    printf(2, "leftovers: %s\n", s);
    panic("syntax");
  }
  nulterminate(cmd);
     bc5:	89 34 24             	mov    %esi,(%esp)
     bc8:	e8 13 ff ff ff       	call   ae0 <nulterminate>
  return cmd;
}
     bcd:	83 c4 14             	add    $0x14,%esp
     bd0:	89 f0                	mov    %esi,%eax
     bd2:	5b                   	pop    %ebx
     bd3:	5e                   	pop    %esi
     bd4:	c3                   	ret    
  
  es = s + strlen(s);
  cmd = parseline(&s, es);
  peek(&s, es, "");
  if(s != es){
    printf(2, "leftovers: %s\n", s);
     bd5:	89 44 24 08          	mov    %eax,0x8(%esp)
     bd9:	c7 44 24 04 0a 13 00 	movl   $0x130a,0x4(%esp)
     be0:	00 
     be1:	c7 04 24 02 00 00 00 	movl   $0x2,(%esp)
     be8:	e8 c3 03 00 00       	call   fb0 <printf>
    panic("syntax");
     bed:	c7 04 24 ce 12 00 00 	movl   $0x12ce,(%esp)
     bf4:	e8 67 f5 ff ff       	call   160 <panic>
     bf9:	90                   	nop
     bfa:	90                   	nop
     bfb:	90                   	nop
     bfc:	90                   	nop
     bfd:	90                   	nop
     bfe:	90                   	nop
     bff:	90                   	nop

00000c00 <strcpy>:
#include "user.h"
#include "x86.h"

char*
strcpy(char *s, char *t)
{
     c00:	53                   	push   %ebx
     c01:	8b 44 24 08          	mov    0x8(%esp),%eax
  char *os;

  os = s;
  while((*s++ = *t++) != 0)
     c05:	31 d2                	xor    %edx,%edx
#include "user.h"
#include "x86.h"

char*
strcpy(char *s, char *t)
{
     c07:	8b 5c 24 0c          	mov    0xc(%esp),%ebx
     c0b:	90                   	nop
     c0c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  char *os;

  os = s;
  while((*s++ = *t++) != 0)
     c10:	0f b6 0c 13          	movzbl (%ebx,%edx,1),%ecx
     c14:	88 0c 10             	mov    %cl,(%eax,%edx,1)
     c17:	83 c2 01             	add    $0x1,%edx
     c1a:	84 c9                	test   %cl,%cl
     c1c:	75 f2                	jne    c10 <strcpy+0x10>
    ;
  return os;
}
     c1e:	5b                   	pop    %ebx
     c1f:	c3                   	ret    

00000c20 <strcmp>:

int
strcmp(const char *p, const char *q)
{
     c20:	56                   	push   %esi
     c21:	53                   	push   %ebx
     c22:	8b 4c 24 0c          	mov    0xc(%esp),%ecx
     c26:	8b 54 24 10          	mov    0x10(%esp),%edx
  while(*p && *p == *q)
     c2a:	0f b6 01             	movzbl (%ecx),%eax
     c2d:	0f b6 1a             	movzbl (%edx),%ebx
     c30:	84 c0                	test   %al,%al
     c32:	74 24                	je     c58 <strcmp+0x38>
     c34:	38 d8                	cmp    %bl,%al
     c36:	74 11                	je     c49 <strcmp+0x29>
     c38:	eb 2e                	jmp    c68 <strcmp+0x48>
     c3a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
     c40:	83 c1 01             	add    $0x1,%ecx
     c43:	38 d8                	cmp    %bl,%al
     c45:	75 21                	jne    c68 <strcmp+0x48>
    p++, q++;
     c47:	89 f2                	mov    %esi,%edx
}

int
strcmp(const char *p, const char *q)
{
  while(*p && *p == *q)
     c49:	0f b6 41 01          	movzbl 0x1(%ecx),%eax
    p++, q++;
     c4d:	8d 72 01             	lea    0x1(%edx),%esi
}

int
strcmp(const char *p, const char *q)
{
  while(*p && *p == *q)
     c50:	0f b6 5a 01          	movzbl 0x1(%edx),%ebx
     c54:	84 c0                	test   %al,%al
     c56:	75 e8                	jne    c40 <strcmp+0x20>
    p++, q++;
  return (uchar)*p - (uchar)*q;
     c58:	0f b6 db             	movzbl %bl,%ebx
}

int
strcmp(const char *p, const char *q)
{
  while(*p && *p == *q)
     c5b:	31 c0                	xor    %eax,%eax
    p++, q++;
  return (uchar)*p - (uchar)*q;
     c5d:	29 d8                	sub    %ebx,%eax
}
     c5f:	5b                   	pop    %ebx
     c60:	5e                   	pop    %esi
     c61:	c3                   	ret    
     c62:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
int
strcmp(const char *p, const char *q)
{
  while(*p && *p == *q)
    p++, q++;
  return (uchar)*p - (uchar)*q;
     c68:	0f b6 db             	movzbl %bl,%ebx
}

int
strcmp(const char *p, const char *q)
{
  while(*p && *p == *q)
     c6b:	0f b6 c0             	movzbl %al,%eax
    p++, q++;
  return (uchar)*p - (uchar)*q;
     c6e:	29 d8                	sub    %ebx,%eax
}
     c70:	5b                   	pop    %ebx
     c71:	5e                   	pop    %esi
     c72:	c3                   	ret    
     c73:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
     c79:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00000c80 <strlen>:

uint
strlen(char *s)
{
     c80:	8b 4c 24 04          	mov    0x4(%esp),%ecx
  int n;

  for(n = 0; s[n]; n++)
     c84:	31 c0                	xor    %eax,%eax
     c86:	80 39 00             	cmpb   $0x0,(%ecx)
     c89:	74 10                	je     c9b <strlen+0x1b>
     c8b:	31 d2                	xor    %edx,%edx
     c8d:	8d 76 00             	lea    0x0(%esi),%esi
     c90:	83 c2 01             	add    $0x1,%edx
     c93:	80 3c 11 00          	cmpb   $0x0,(%ecx,%edx,1)
     c97:	89 d0                	mov    %edx,%eax
     c99:	75 f5                	jne    c90 <strlen+0x10>
    ;
  return n;
}
     c9b:	f3 c3                	repz ret 
     c9d:	8d 76 00             	lea    0x0(%esi),%esi

00000ca0 <memset>:

void*
memset(void *dst, int c, uint n)
{
     ca0:	57                   	push   %edi
     ca1:	8b 54 24 08          	mov    0x8(%esp),%edx
}

static inline void
stosb(void *addr, int data, int cnt)
{
  asm volatile("cld; rep stosb" :
     ca5:	8b 4c 24 10          	mov    0x10(%esp),%ecx
     ca9:	8b 44 24 0c          	mov    0xc(%esp),%eax
     cad:	89 d7                	mov    %edx,%edi
     caf:	fc                   	cld    
     cb0:	f3 aa                	rep stos %al,%es:(%edi)
  stosb(dst, c, n);
  return dst;
}
     cb2:	89 d0                	mov    %edx,%eax
     cb4:	5f                   	pop    %edi
     cb5:	c3                   	ret    
     cb6:	8d 76 00             	lea    0x0(%esi),%esi
     cb9:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00000cc0 <strchr>:

char*
strchr(const char *s, char c)
{
     cc0:	8b 44 24 04          	mov    0x4(%esp),%eax
     cc4:	0f b6 4c 24 08       	movzbl 0x8(%esp),%ecx
  for(; *s; s++)
     cc9:	0f b6 10             	movzbl (%eax),%edx
     ccc:	84 d2                	test   %dl,%dl
     cce:	74 1d                	je     ced <strchr+0x2d>
    if(*s == c)
     cd0:	38 ca                	cmp    %cl,%dl
     cd2:	75 0e                	jne    ce2 <strchr+0x22>
     cd4:	eb 1c                	jmp    cf2 <strchr+0x32>
     cd6:	66 90                	xchg   %ax,%ax
}

char*
strchr(const char *s, char c)
{
  for(; *s; s++)
     cd8:	83 c0 01             	add    $0x1,%eax
    if(*s == c)
     cdb:	38 ca                	cmp    %cl,%dl
     cdd:	8d 76 00             	lea    0x0(%esi),%esi
     ce0:	74 0e                	je     cf0 <strchr+0x30>
}

char*
strchr(const char *s, char c)
{
  for(; *s; s++)
     ce2:	0f b6 50 01          	movzbl 0x1(%eax),%edx
     ce6:	84 d2                	test   %dl,%dl
     ce8:	75 ee                	jne    cd8 <strchr+0x18>
    if(*s == c)
      return (char*) s;
  return 0;
     cea:	31 c0                	xor    %eax,%eax
     cec:	c3                   	ret    
     ced:	31 c0                	xor    %eax,%eax
     cef:	90                   	nop
}
     cf0:	f3 c3                	repz ret 
     cf2:	f3 c3                	repz ret 
     cf4:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
     cfa:	8d bf 00 00 00 00    	lea    0x0(%edi),%edi

00000d00 <gets>:

char*
gets(char *buf, int max)
{
     d00:	55                   	push   %ebp
     d01:	57                   	push   %edi
     d02:	56                   	push   %esi
  int i, cc;
  char c;

  for(i=0; i+1 < max; ){
     d03:	31 f6                	xor    %esi,%esi
  return 0;
}

char*
gets(char *buf, int max)
{
     d05:	53                   	push   %ebx
     d06:	83 ec 2c             	sub    $0x2c,%esp
     d09:	8b 7c 24 40          	mov    0x40(%esp),%edi
     d0d:	8b 6c 24 44          	mov    0x44(%esp),%ebp
  int i, cc;
  char c;

  for(i=0; i+1 < max; ){
     d11:	eb 38                	jmp    d4b <gets+0x4b>
     d13:	90                   	nop
     d14:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
    cc = read(0, &c, 1);
     d18:	8d 44 24 1f          	lea    0x1f(%esp),%eax
     d1c:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
     d23:	00 
     d24:	89 44 24 04          	mov    %eax,0x4(%esp)
     d28:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
     d2f:	e8 48 01 00 00       	call   e7c <read>
    if(cc < 1)
     d34:	85 c0                	test   %eax,%eax
     d36:	7e 1a                	jle    d52 <gets+0x52>
      break;
    buf[i++] = c;
     d38:	0f b6 44 24 1f       	movzbl 0x1f(%esp),%eax
gets(char *buf, int max)
{
  int i, cc;
  char c;

  for(i=0; i+1 < max; ){
     d3d:	89 de                	mov    %ebx,%esi
    cc = read(0, &c, 1);
    if(cc < 1)
      break;
    buf[i++] = c;
    if(c == '\n' || c == '\r')
     d3f:	3c 0d                	cmp    $0xd,%al

  for(i=0; i+1 < max; ){
    cc = read(0, &c, 1);
    if(cc < 1)
      break;
    buf[i++] = c;
     d41:	88 44 1f ff          	mov    %al,-0x1(%edi,%ebx,1)
    if(c == '\n' || c == '\r')
     d45:	74 0b                	je     d52 <gets+0x52>
     d47:	3c 0a                	cmp    $0xa,%al
     d49:	74 07                	je     d52 <gets+0x52>
gets(char *buf, int max)
{
  int i, cc;
  char c;

  for(i=0; i+1 < max; ){
     d4b:	8d 5e 01             	lea    0x1(%esi),%ebx
     d4e:	39 eb                	cmp    %ebp,%ebx
     d50:	7c c6                	jl     d18 <gets+0x18>
      break;
    buf[i++] = c;
    if(c == '\n' || c == '\r')
      break;
  }
  buf[i] = '\0';
     d52:	c6 04 37 00          	movb   $0x0,(%edi,%esi,1)
  return buf;
}
     d56:	83 c4 2c             	add    $0x2c,%esp
     d59:	89 f8                	mov    %edi,%eax
     d5b:	5b                   	pop    %ebx
     d5c:	5e                   	pop    %esi
     d5d:	5f                   	pop    %edi
     d5e:	5d                   	pop    %ebp
     d5f:	c3                   	ret    

00000d60 <stat>:

int
stat(char *n, struct statt *st)
{
     d60:	83 ec 1c             	sub    $0x1c,%esp
  int fd;
  int r;

  fd = open(n, O_RDONLY);
     d63:	8b 44 24 20          	mov    0x20(%esp),%eax
  return buf;
}

int
stat(char *n, struct statt *st)
{
     d67:	89 5c 24 14          	mov    %ebx,0x14(%esp)
     d6b:	89 74 24 18          	mov    %esi,0x18(%esp)
  int fd;
  int r;

  fd = open(n, O_RDONLY);
  if(fd < 0)
    return -1;
     d6f:	be ff ff ff ff       	mov    $0xffffffff,%esi
stat(char *n, struct statt *st)
{
  int fd;
  int r;

  fd = open(n, O_RDONLY);
     d74:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
     d7b:	00 
     d7c:	89 04 24             	mov    %eax,(%esp)
     d7f:	e8 20 01 00 00       	call   ea4 <open>
  if(fd < 0)
     d84:	85 c0                	test   %eax,%eax
stat(char *n, struct statt *st)
{
  int fd;
  int r;

  fd = open(n, O_RDONLY);
     d86:	89 c3                	mov    %eax,%ebx
  if(fd < 0)
     d88:	78 1a                	js     da4 <stat+0x44>
    return -1;
  r = fstat(fd, st);
     d8a:	8b 44 24 24          	mov    0x24(%esp),%eax
     d8e:	89 1c 24             	mov    %ebx,(%esp)
     d91:	89 44 24 04          	mov    %eax,0x4(%esp)
     d95:	e8 22 01 00 00       	call   ebc <fstat>
  close(fd);
     d9a:	89 1c 24             	mov    %ebx,(%esp)
  int r;

  fd = open(n, O_RDONLY);
  if(fd < 0)
    return -1;
  r = fstat(fd, st);
     d9d:	89 c6                	mov    %eax,%esi
  close(fd);
     d9f:	e8 e8 00 00 00       	call   e8c <close>
  return r;
}
     da4:	89 f0                	mov    %esi,%eax
     da6:	8b 5c 24 14          	mov    0x14(%esp),%ebx
     daa:	8b 74 24 18          	mov    0x18(%esp),%esi
     dae:	83 c4 1c             	add    $0x1c,%esp
     db1:	c3                   	ret    
     db2:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
     db9:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00000dc0 <atoi>:

int
atoi(const char *s)
{
     dc0:	53                   	push   %ebx
     dc1:	8b 4c 24 08          	mov    0x8(%esp),%ecx
  int n;

  n = 0;
     dc5:	31 c0                	xor    %eax,%eax
  while('0' <= *s && *s <= '9')
     dc7:	0f b6 11             	movzbl (%ecx),%edx
     dca:	8d 5a d0             	lea    -0x30(%edx),%ebx
     dcd:	80 fb 09             	cmp    $0x9,%bl
     dd0:	77 1e                	ja     df0 <atoi+0x30>
     dd2:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
    n = n*10 + *s++ - '0';
     dd8:	0f be d2             	movsbl %dl,%edx
     ddb:	83 c1 01             	add    $0x1,%ecx
     dde:	8d 04 80             	lea    (%eax,%eax,4),%eax
     de1:	8d 44 42 d0          	lea    -0x30(%edx,%eax,2),%eax
atoi(const char *s)
{
  int n;

  n = 0;
  while('0' <= *s && *s <= '9')
     de5:	0f b6 11             	movzbl (%ecx),%edx
     de8:	8d 5a d0             	lea    -0x30(%edx),%ebx
     deb:	80 fb 09             	cmp    $0x9,%bl
     dee:	76 e8                	jbe    dd8 <atoi+0x18>
    n = n*10 + *s++ - '0';
  return n;
}
     df0:	5b                   	pop    %ebx
     df1:	c3                   	ret    
     df2:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
     df9:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00000e00 <memmove>:

void*
memmove(void *vdst, void *vsrc, int n)
{
     e00:	56                   	push   %esi
     e01:	53                   	push   %ebx
     e02:	8b 5c 24 14          	mov    0x14(%esp),%ebx
     e06:	8b 44 24 0c          	mov    0xc(%esp),%eax
     e0a:	8b 74 24 10          	mov    0x10(%esp),%esi
  char *dst, *src;
  
  dst = vdst;
  src = vsrc;
  while(n-- > 0)
     e0e:	85 db                	test   %ebx,%ebx
     e10:	7e 14                	jle    e26 <memmove+0x26>
    n = n*10 + *s++ - '0';
  return n;
}

void*
memmove(void *vdst, void *vsrc, int n)
     e12:	31 d2                	xor    %edx,%edx
     e14:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  char *dst, *src;
  
  dst = vdst;
  src = vsrc;
  while(n-- > 0)
    *dst++ = *src++;
     e18:	0f b6 0c 16          	movzbl (%esi,%edx,1),%ecx
     e1c:	88 0c 10             	mov    %cl,(%eax,%edx,1)
     e1f:	83 c2 01             	add    $0x1,%edx
{
  char *dst, *src;
  
  dst = vdst;
  src = vsrc;
  while(n-- > 0)
     e22:	39 da                	cmp    %ebx,%edx
     e24:	75 f2                	jne    e18 <memmove+0x18>
    *dst++ = *src++;
  return vdst;
}
     e26:	5b                   	pop    %ebx
     e27:	5e                   	pop    %esi
     e28:	c3                   	ret    
     e29:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi

00000e30 <memcpy>:

void *
memcpy(void *dst, const void *src, uint n)
{
     e30:	56                   	push   %esi
     e31:	53                   	push   %ebx
     e32:	8b 5c 24 14          	mov    0x14(%esp),%ebx
     e36:	8b 44 24 0c          	mov    0xc(%esp),%eax
     e3a:	8b 74 24 10          	mov    0x10(%esp),%esi
{
  char *dst, *src;
  
  dst = vdst;
  src = vsrc;
  while(n-- > 0)
     e3e:	85 db                	test   %ebx,%ebx
     e40:	7e 14                	jle    e56 <memcpy+0x26>
     e42:	31 d2                	xor    %edx,%edx
     e44:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
    *dst++ = *src++;
     e48:	0f b6 0c 16          	movzbl (%esi,%edx,1),%ecx
     e4c:	88 0c 10             	mov    %cl,(%eax,%edx,1)
     e4f:	83 c2 01             	add    $0x1,%edx
{
  char *dst, *src;
  
  dst = vdst;
  src = vsrc;
  while(n-- > 0)
     e52:	39 da                	cmp    %ebx,%edx
     e54:	75 f2                	jne    e48 <memcpy+0x18>

void *
memcpy(void *dst, const void *src, uint n)
{
  return memmove(dst, src, n);
}
     e56:	5b                   	pop    %ebx
     e57:	5e                   	pop    %esi
     e58:	c3                   	ret    
     e59:	90                   	nop
     e5a:	90                   	nop
     e5b:	90                   	nop

00000e5c <fork>:
     e5c:	b8 01 00 00 00       	mov    $0x1,%eax
     e61:	cd 40                	int    $0x40
     e63:	c3                   	ret    

00000e64 <exit>:
     e64:	b8 02 00 00 00       	mov    $0x2,%eax
     e69:	cd 40                	int    $0x40
     e6b:	c3                   	ret    

00000e6c <wait>:
     e6c:	b8 03 00 00 00       	mov    $0x3,%eax
     e71:	cd 40                	int    $0x40
     e73:	c3                   	ret    

00000e74 <pipe>:
     e74:	b8 04 00 00 00       	mov    $0x4,%eax
     e79:	cd 40                	int    $0x40
     e7b:	c3                   	ret    

00000e7c <read>:
     e7c:	b8 06 00 00 00       	mov    $0x6,%eax
     e81:	cd 40                	int    $0x40
     e83:	c3                   	ret    

00000e84 <write>:
     e84:	b8 05 00 00 00       	mov    $0x5,%eax
     e89:	cd 40                	int    $0x40
     e8b:	c3                   	ret    

00000e8c <close>:
     e8c:	b8 07 00 00 00       	mov    $0x7,%eax
     e91:	cd 40                	int    $0x40
     e93:	c3                   	ret    

00000e94 <kill>:
     e94:	b8 08 00 00 00       	mov    $0x8,%eax
     e99:	cd 40                	int    $0x40
     e9b:	c3                   	ret    

00000e9c <exec>:
     e9c:	b8 09 00 00 00       	mov    $0x9,%eax
     ea1:	cd 40                	int    $0x40
     ea3:	c3                   	ret    

00000ea4 <open>:
     ea4:	b8 0a 00 00 00       	mov    $0xa,%eax
     ea9:	cd 40                	int    $0x40
     eab:	c3                   	ret    

00000eac <mknod>:
     eac:	b8 0b 00 00 00       	mov    $0xb,%eax
     eb1:	cd 40                	int    $0x40
     eb3:	c3                   	ret    

00000eb4 <unlink>:
     eb4:	b8 0c 00 00 00       	mov    $0xc,%eax
     eb9:	cd 40                	int    $0x40
     ebb:	c3                   	ret    

00000ebc <fstat>:
     ebc:	b8 0d 00 00 00       	mov    $0xd,%eax
     ec1:	cd 40                	int    $0x40
     ec3:	c3                   	ret    

00000ec4 <link>:
     ec4:	b8 0e 00 00 00       	mov    $0xe,%eax
     ec9:	cd 40                	int    $0x40
     ecb:	c3                   	ret    

00000ecc <mkdir>:
     ecc:	b8 0f 00 00 00       	mov    $0xf,%eax
     ed1:	cd 40                	int    $0x40
     ed3:	c3                   	ret    

00000ed4 <chdir>:
     ed4:	b8 10 00 00 00       	mov    $0x10,%eax
     ed9:	cd 40                	int    $0x40
     edb:	c3                   	ret    

00000edc <dup>:
     edc:	b8 11 00 00 00       	mov    $0x11,%eax
     ee1:	cd 40                	int    $0x40
     ee3:	c3                   	ret    

00000ee4 <getpid>:
     ee4:	b8 12 00 00 00       	mov    $0x12,%eax
     ee9:	cd 40                	int    $0x40
     eeb:	c3                   	ret    

00000eec <sbrk>:
     eec:	b8 13 00 00 00       	mov    $0x13,%eax
     ef1:	cd 40                	int    $0x40
     ef3:	c3                   	ret    

00000ef4 <sleep>:
     ef4:	b8 14 00 00 00       	mov    $0x14,%eax
     ef9:	cd 40                	int    $0x40
     efb:	c3                   	ret    
     efc:	90                   	nop
     efd:	90                   	nop
     efe:	90                   	nop
     eff:	90                   	nop

00000f00 <putc>:
#include "stat.h"
#include "user.h"

static void
putc(int fd, char c)
{
     f00:	83 ec 2c             	sub    $0x2c,%esp
     f03:	88 54 24 1c          	mov    %dl,0x1c(%esp)
  write(fd, &c, 1);
     f07:	8d 54 24 1c          	lea    0x1c(%esp),%edx
     f0b:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
     f12:	00 
     f13:	89 54 24 04          	mov    %edx,0x4(%esp)
     f17:	89 04 24             	mov    %eax,(%esp)
     f1a:	e8 65 ff ff ff       	call   e84 <write>
}
     f1f:	83 c4 2c             	add    $0x2c,%esp
     f22:	c3                   	ret    
     f23:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
     f29:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00000f30 <printint>:

static void
printint(int fd, int xx, int base, int sgn)
{
     f30:	57                   	push   %edi
     f31:	56                   	push   %esi
     f32:	53                   	push   %ebx
     f33:	89 c3                	mov    %eax,%ebx
     f35:	83 ec 10             	sub    $0x10,%esp
  char buf[16];
  int i, neg;
  uint x;

  neg = 0;
  if(sgn && xx < 0){
     f38:	8b 44 24 20          	mov    0x20(%esp),%eax
     f3c:	85 c0                	test   %eax,%eax
     f3e:	74 60                	je     fa0 <printint+0x70>
     f40:	89 d0                	mov    %edx,%eax
     f42:	c1 e8 1f             	shr    $0x1f,%eax
     f45:	84 c0                	test   %al,%al
     f47:	74 57                	je     fa0 <printint+0x70>
    neg = 1;
    x = -xx;
     f49:	89 d0                	mov    %edx,%eax
  int i, neg;
  uint x;

  neg = 0;
  if(sgn && xx < 0){
    neg = 1;
     f4b:	bf 01 00 00 00       	mov    $0x1,%edi
    x = -xx;
     f50:	f7 d8                	neg    %eax
  } else {
    x = xx;
  }

  i = 0;
     f52:	31 f6                	xor    %esi,%esi
     f54:	eb 04                	jmp    f5a <printint+0x2a>
     f56:	66 90                	xchg   %ax,%ax
  do{
    buf[i++] = digits[x % base];
     f58:	89 d6                	mov    %edx,%esi
     f5a:	31 d2                	xor    %edx,%edx
     f5c:	f7 f1                	div    %ecx
     f5e:	0f b6 92 67 13 00 00 	movzbl 0x1367(%edx),%edx
  }while((x /= base) != 0);
     f65:	85 c0                	test   %eax,%eax
    x = xx;
  }

  i = 0;
  do{
    buf[i++] = digits[x % base];
     f67:	88 14 34             	mov    %dl,(%esp,%esi,1)
     f6a:	8d 56 01             	lea    0x1(%esi),%edx
  }while((x /= base) != 0);
     f6d:	75 e9                	jne    f58 <printint+0x28>
  if(neg)
     f6f:	85 ff                	test   %edi,%edi
     f71:	74 07                	je     f7a <printint+0x4a>
    buf[i++] = '-';
     f73:	c6 04 14 2d          	movb   $0x2d,(%esp,%edx,1)
     f77:	8d 56 02             	lea    0x2(%esi),%edx

  while(--i >= 0)
     f7a:	8d 72 ff             	lea    -0x1(%edx),%esi
     f7d:	8d 76 00             	lea    0x0(%esi),%esi
    putc(fd, buf[i]);
     f80:	0f be 14 34          	movsbl (%esp,%esi,1),%edx
     f84:	89 d8                	mov    %ebx,%eax
    buf[i++] = digits[x % base];
  }while((x /= base) != 0);
  if(neg)
    buf[i++] = '-';

  while(--i >= 0)
     f86:	83 ee 01             	sub    $0x1,%esi
    putc(fd, buf[i]);
     f89:	e8 72 ff ff ff       	call   f00 <putc>
    buf[i++] = digits[x % base];
  }while((x /= base) != 0);
  if(neg)
    buf[i++] = '-';

  while(--i >= 0)
     f8e:	83 fe ff             	cmp    $0xffffffff,%esi
     f91:	75 ed                	jne    f80 <printint+0x50>
    putc(fd, buf[i]);
}
     f93:	83 c4 10             	add    $0x10,%esp
     f96:	5b                   	pop    %ebx
     f97:	5e                   	pop    %esi
     f98:	5f                   	pop    %edi
     f99:	c3                   	ret    
     f9a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  neg = 0;
  if(sgn && xx < 0){
    neg = 1;
    x = -xx;
  } else {
    x = xx;
     fa0:	89 d0                	mov    %edx,%eax
  static char digits[] = "0123456789ABCDEF";
  char buf[16];
  int i, neg;
  uint x;

  neg = 0;
     fa2:	31 ff                	xor    %edi,%edi
     fa4:	eb ac                	jmp    f52 <printint+0x22>
     fa6:	8d 76 00             	lea    0x0(%esi),%esi
     fa9:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00000fb0 <printf>:
}

// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
     fb0:	55                   	push   %ebp
     fb1:	57                   	push   %edi
     fb2:	56                   	push   %esi
     fb3:	53                   	push   %ebx
     fb4:	83 ec 2c             	sub    $0x2c,%esp
  int c, i, state;
  uint *ap;

  state = 0;
  ap = (uint*)(void*)&fmt + 1;
  for(i = 0; fmt[i]; i++){
     fb7:	8b 5c 24 44          	mov    0x44(%esp),%ebx
}

// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
     fbb:	8b 6c 24 40          	mov    0x40(%esp),%ebp
  int c, i, state;
  uint *ap;

  state = 0;
  ap = (uint*)(void*)&fmt + 1;
  for(i = 0; fmt[i]; i++){
     fbf:	0f b6 0b             	movzbl (%ebx),%ecx
     fc2:	84 c9                	test   %cl,%cl
     fc4:	0f 84 86 00 00 00    	je     1050 <printf+0xa0>
  char *s;
  int c, i, state;
  uint *ap;

  state = 0;
  ap = (uint*)(void*)&fmt + 1;
     fca:	8d 44 24 48          	lea    0x48(%esp),%eax
{
  char *s;
  int c, i, state;
  uint *ap;

  state = 0;
     fce:	31 f6                	xor    %esi,%esi
  ap = (uint*)(void*)&fmt + 1;
     fd0:	89 44 24 1c          	mov    %eax,0x1c(%esp)
     fd4:	eb 1b                	jmp    ff1 <printf+0x41>
     fd6:	66 90                	xchg   %ax,%ax
  for(i = 0; fmt[i]; i++){
    c = fmt[i] & 0xff;
    if(state == 0){
      if(c == '%'){
     fd8:	83 f9 25             	cmp    $0x25,%ecx
     fdb:	74 7b                	je     1058 <printf+0xa8>
        state = '%';
      } else {
        putc(fd, c);
     fdd:	0f be d1             	movsbl %cl,%edx
     fe0:	89 e8                	mov    %ebp,%eax
     fe2:	e8 19 ff ff ff       	call   f00 <putc>
      } else if(c == '%'){
        putc(fd, c);
      } else {
        // Unknown % sequence.  Print it to draw attention.
        putc(fd, '%');
        putc(fd, c);
     fe7:	83 c3 01             	add    $0x1,%ebx
  int c, i, state;
  uint *ap;

  state = 0;
  ap = (uint*)(void*)&fmt + 1;
  for(i = 0; fmt[i]; i++){
     fea:	0f b6 0b             	movzbl (%ebx),%ecx
     fed:	84 c9                	test   %cl,%cl
     fef:	74 5f                	je     1050 <printf+0xa0>
    c = fmt[i] & 0xff;
    if(state == 0){
     ff1:	85 f6                	test   %esi,%esi
  uint *ap;

  state = 0;
  ap = (uint*)(void*)&fmt + 1;
  for(i = 0; fmt[i]; i++){
    c = fmt[i] & 0xff;
     ff3:	0f b6 c9             	movzbl %cl,%ecx
    if(state == 0){
     ff6:	74 e0                	je     fd8 <printf+0x28>
      if(c == '%'){
        state = '%';
      } else {
        putc(fd, c);
      }
    } else if(state == '%'){
     ff8:	83 fe 25             	cmp    $0x25,%esi
     ffb:	75 ea                	jne    fe7 <printf+0x37>
      if(c == 'd'){
     ffd:	83 f9 64             	cmp    $0x64,%ecx
    1000:	0f 84 ba 00 00 00    	je     10c0 <printf+0x110>
        printint(fd, *ap, 10, 1);
        ap++;
      } else if(c == 'x' || c == 'p'){
    1006:	83 f9 70             	cmp    $0x70,%ecx
    1009:	74 55                	je     1060 <printf+0xb0>
    100b:	83 f9 78             	cmp    $0x78,%ecx
    100e:	66 90                	xchg   %ax,%ax
    1010:	74 4e                	je     1060 <printf+0xb0>
        printint(fd, *ap, 16, 0);
        ap++;
      } else if(c == 's'){
    1012:	83 f9 73             	cmp    $0x73,%ecx
    1015:	74 71                	je     1088 <printf+0xd8>
          s = "(null)";
        while(*s != 0){
          putc(fd, *s);
          s++;
        }
      } else if(c == 'c'){
    1017:	83 f9 63             	cmp    $0x63,%ecx
    101a:	0f 84 c3 00 00 00    	je     10e3 <printf+0x133>
        putc(fd, *ap);
        ap++;
      } else if(c == '%'){
    1020:	83 f9 25             	cmp    $0x25,%ecx
        putc(fd, c);
    1023:	ba 25 00 00 00       	mov    $0x25,%edx
    1028:	89 e8                	mov    %ebp,%eax
          s++;
        }
      } else if(c == 'c'){
        putc(fd, *ap);
        ap++;
      } else if(c == '%'){
    102a:	74 12                	je     103e <printf+0x8e>
        putc(fd, c);
      } else {
        // Unknown % sequence.  Print it to draw attention.
        putc(fd, '%');
    102c:	89 4c 24 18          	mov    %ecx,0x18(%esp)
    1030:	e8 cb fe ff ff       	call   f00 <putc>
        putc(fd, c);
    1035:	8b 4c 24 18          	mov    0x18(%esp),%ecx
    1039:	89 e8                	mov    %ebp,%eax
    103b:	0f be d1             	movsbl %cl,%edx
    103e:	e8 bd fe ff ff       	call   f00 <putc>
      }
      state = 0;
    1043:	31 f6                	xor    %esi,%esi
      } else if(c == '%'){
        putc(fd, c);
      } else {
        // Unknown % sequence.  Print it to draw attention.
        putc(fd, '%');
        putc(fd, c);
    1045:	83 c3 01             	add    $0x1,%ebx
  int c, i, state;
  uint *ap;

  state = 0;
  ap = (uint*)(void*)&fmt + 1;
  for(i = 0; fmt[i]; i++){
    1048:	0f b6 0b             	movzbl (%ebx),%ecx
    104b:	84 c9                	test   %cl,%cl
    104d:	75 a2                	jne    ff1 <printf+0x41>
    104f:	90                   	nop
        putc(fd, c);
      }
      state = 0;
    }
  }
}
    1050:	83 c4 2c             	add    $0x2c,%esp
    1053:	5b                   	pop    %ebx
    1054:	5e                   	pop    %esi
    1055:	5f                   	pop    %edi
    1056:	5d                   	pop    %ebp
    1057:	c3                   	ret    
  ap = (uint*)(void*)&fmt + 1;
  for(i = 0; fmt[i]; i++){
    c = fmt[i] & 0xff;
    if(state == 0){
      if(c == '%'){
        state = '%';
    1058:	be 25 00 00 00       	mov    $0x25,%esi
    105d:	eb 88                	jmp    fe7 <printf+0x37>
    105f:	90                   	nop
    } else if(state == '%'){
      if(c == 'd'){
        printint(fd, *ap, 10, 1);
        ap++;
      } else if(c == 'x' || c == 'p'){
        printint(fd, *ap, 16, 0);
    1060:	8b 44 24 1c          	mov    0x1c(%esp),%eax
    1064:	b9 10 00 00 00       	mov    $0x10,%ecx
      } else {
        // Unknown % sequence.  Print it to draw attention.
        putc(fd, '%');
        putc(fd, c);
      }
      state = 0;
    1069:	31 f6                	xor    %esi,%esi
    } else if(state == '%'){
      if(c == 'd'){
        printint(fd, *ap, 10, 1);
        ap++;
      } else if(c == 'x' || c == 'p'){
        printint(fd, *ap, 16, 0);
    106b:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
    1072:	8b 10                	mov    (%eax),%edx
    1074:	89 e8                	mov    %ebp,%eax
    1076:	e8 b5 fe ff ff       	call   f30 <printint>
        ap++;
    107b:	83 44 24 1c 04       	addl   $0x4,0x1c(%esp)
    1080:	e9 62 ff ff ff       	jmp    fe7 <printf+0x37>
    1085:	8d 76 00             	lea    0x0(%esi),%esi
      } else if(c == 's'){
        s = (char*)*ap;
    1088:	8b 44 24 1c          	mov    0x1c(%esp),%eax
    108c:	8b 38                	mov    (%eax),%edi
        ap++;
    108e:	83 c0 04             	add    $0x4,%eax
    1091:	89 44 24 1c          	mov    %eax,0x1c(%esp)
        if(s == 0)
    1095:	85 ff                	test   %edi,%edi
    1097:	74 64                	je     10fd <printf+0x14d>
          s = "(null)";
        while(*s != 0){
    1099:	0f b6 17             	movzbl (%edi),%edx
      } else {
        // Unknown % sequence.  Print it to draw attention.
        putc(fd, '%');
        putc(fd, c);
      }
      state = 0;
    109c:	31 f6                	xor    %esi,%esi
      } else if(c == 's'){
        s = (char*)*ap;
        ap++;
        if(s == 0)
          s = "(null)";
        while(*s != 0){
    109e:	84 d2                	test   %dl,%dl
    10a0:	0f 84 41 ff ff ff    	je     fe7 <printf+0x37>
    10a6:	66 90                	xchg   %ax,%ax
          putc(fd, *s);
    10a8:	0f be d2             	movsbl %dl,%edx
          s++;
    10ab:	83 c7 01             	add    $0x1,%edi
        s = (char*)*ap;
        ap++;
        if(s == 0)
          s = "(null)";
        while(*s != 0){
          putc(fd, *s);
    10ae:	89 e8                	mov    %ebp,%eax
    10b0:	e8 4b fe ff ff       	call   f00 <putc>
      } else if(c == 's'){
        s = (char*)*ap;
        ap++;
        if(s == 0)
          s = "(null)";
        while(*s != 0){
    10b5:	0f b6 17             	movzbl (%edi),%edx
    10b8:	84 d2                	test   %dl,%dl
    10ba:	75 ec                	jne    10a8 <printf+0xf8>
      } else {
        // Unknown % sequence.  Print it to draw attention.
        putc(fd, '%');
        putc(fd, c);
      }
      state = 0;
    10bc:	31 f6                	xor    %esi,%esi
    10be:	eb 85                	jmp    1045 <printf+0x95>
      } else {
        putc(fd, c);
      }
    } else if(state == '%'){
      if(c == 'd'){
        printint(fd, *ap, 10, 1);
    10c0:	8b 44 24 1c          	mov    0x1c(%esp),%eax
    10c4:	b1 0a                	mov    $0xa,%cl
      } else {
        // Unknown % sequence.  Print it to draw attention.
        putc(fd, '%');
        putc(fd, c);
      }
      state = 0;
    10c6:	66 31 f6             	xor    %si,%si
      } else {
        putc(fd, c);
      }
    } else if(state == '%'){
      if(c == 'd'){
        printint(fd, *ap, 10, 1);
    10c9:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
    10d0:	8b 10                	mov    (%eax),%edx
    10d2:	89 e8                	mov    %ebp,%eax
    10d4:	e8 57 fe ff ff       	call   f30 <printint>
        ap++;
    10d9:	83 44 24 1c 04       	addl   $0x4,0x1c(%esp)
    10de:	e9 04 ff ff ff       	jmp    fe7 <printf+0x37>
        while(*s != 0){
          putc(fd, *s);
          s++;
        }
      } else if(c == 'c'){
        putc(fd, *ap);
    10e3:	8b 44 24 1c          	mov    0x1c(%esp),%eax
      } else {
        // Unknown % sequence.  Print it to draw attention.
        putc(fd, '%');
        putc(fd, c);
      }
      state = 0;
    10e7:	31 f6                	xor    %esi,%esi
        while(*s != 0){
          putc(fd, *s);
          s++;
        }
      } else if(c == 'c'){
        putc(fd, *ap);
    10e9:	0f be 10             	movsbl (%eax),%edx
    10ec:	89 e8                	mov    %ebp,%eax
    10ee:	e8 0d fe ff ff       	call   f00 <putc>
        ap++;
    10f3:	83 44 24 1c 04       	addl   $0x4,0x1c(%esp)
    10f8:	e9 ea fe ff ff       	jmp    fe7 <printf+0x37>
        ap++;
      } else if(c == 's'){
        s = (char*)*ap;
        ap++;
        if(s == 0)
          s = "(null)";
    10fd:	bf 60 13 00 00       	mov    $0x1360,%edi
    1102:	eb 95                	jmp    1099 <printf+0xe9>
    1104:	90                   	nop
    1105:	90                   	nop
    1106:	90                   	nop
    1107:	90                   	nop
    1108:	90                   	nop
    1109:	90                   	nop
    110a:	90                   	nop
    110b:	90                   	nop
    110c:	90                   	nop
    110d:	90                   	nop
    110e:	90                   	nop
    110f:	90                   	nop

00001110 <free>:
static Header base;
static Header *freep;

void
free(void *ap)
{
    1110:	57                   	push   %edi
  Header *bp, *p;

  bp = (Header*) ap - 1;
  for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
    1111:	a1 c4 19 00 00       	mov    0x19c4,%eax
static Header base;
static Header *freep;

void
free(void *ap)
{
    1116:	56                   	push   %esi
    1117:	53                   	push   %ebx
    1118:	8b 5c 24 10          	mov    0x10(%esp),%ebx
  Header *bp, *p;

  bp = (Header*) ap - 1;
    111c:	8d 4b f8             	lea    -0x8(%ebx),%ecx
    111f:	90                   	nop
  for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
    1120:	39 c8                	cmp    %ecx,%eax
    1122:	8b 10                	mov    (%eax),%edx
    1124:	73 04                	jae    112a <free+0x1a>
    1126:	39 d1                	cmp    %edx,%ecx
    1128:	72 16                	jb     1140 <free+0x30>
    if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
    112a:	39 d0                	cmp    %edx,%eax
    112c:	72 08                	jb     1136 <free+0x26>
    112e:	39 c8                	cmp    %ecx,%eax
    1130:	72 0e                	jb     1140 <free+0x30>
    1132:	39 d1                	cmp    %edx,%ecx
    1134:	72 0a                	jb     1140 <free+0x30>
static Header base;
static Header *freep;

void
free(void *ap)
{
    1136:	89 d0                	mov    %edx,%eax
    1138:	eb e6                	jmp    1120 <free+0x10>
    113a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi

  bp = (Header*) ap - 1;
  for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
    if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
      break;
  if(bp + bp->s.size == p->s.ptr){
    1140:	8b 73 fc             	mov    -0x4(%ebx),%esi
    1143:	8d 3c f1             	lea    (%ecx,%esi,8),%edi
    1146:	39 d7                	cmp    %edx,%edi
    1148:	74 18                	je     1162 <free+0x52>
    bp->s.size += p->s.ptr->s.size;
    bp->s.ptr = p->s.ptr->s.ptr;
  } else
    bp->s.ptr = p->s.ptr;
    114a:	89 53 f8             	mov    %edx,-0x8(%ebx)
  if(p + p->s.size == bp){
    114d:	8b 50 04             	mov    0x4(%eax),%edx
    1150:	8d 34 d0             	lea    (%eax,%edx,8),%esi
    1153:	39 f1                	cmp    %esi,%ecx
    1155:	74 22                	je     1179 <free+0x69>
    p->s.size += bp->s.size;
    p->s.ptr = bp->s.ptr;
  } else
    p->s.ptr = bp;
    1157:	89 08                	mov    %ecx,(%eax)
  freep = p;
    1159:	a3 c4 19 00 00       	mov    %eax,0x19c4
}
    115e:	5b                   	pop    %ebx
    115f:	5e                   	pop    %esi
    1160:	5f                   	pop    %edi
    1161:	c3                   	ret    
  bp = (Header*) ap - 1;
  for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
    if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
      break;
  if(bp + bp->s.size == p->s.ptr){
    bp->s.size += p->s.ptr->s.size;
    1162:	03 72 04             	add    0x4(%edx),%esi
    1165:	89 73 fc             	mov    %esi,-0x4(%ebx)
    bp->s.ptr = p->s.ptr->s.ptr;
    1168:	8b 10                	mov    (%eax),%edx
    116a:	8b 12                	mov    (%edx),%edx
    116c:	89 53 f8             	mov    %edx,-0x8(%ebx)
  } else
    bp->s.ptr = p->s.ptr;
  if(p + p->s.size == bp){
    116f:	8b 50 04             	mov    0x4(%eax),%edx
    1172:	8d 34 d0             	lea    (%eax,%edx,8),%esi
    1175:	39 f1                	cmp    %esi,%ecx
    1177:	75 de                	jne    1157 <free+0x47>
    p->s.size += bp->s.size;
    1179:	03 53 fc             	add    -0x4(%ebx),%edx
    p->s.ptr = bp->s.ptr;
  } else
    p->s.ptr = bp;
  freep = p;
    117c:	a3 c4 19 00 00       	mov    %eax,0x19c4
    bp->s.size += p->s.ptr->s.size;
    bp->s.ptr = p->s.ptr->s.ptr;
  } else
    bp->s.ptr = p->s.ptr;
  if(p + p->s.size == bp){
    p->s.size += bp->s.size;
    1181:	89 50 04             	mov    %edx,0x4(%eax)
    p->s.ptr = bp->s.ptr;
    1184:	8b 53 f8             	mov    -0x8(%ebx),%edx
    1187:	89 10                	mov    %edx,(%eax)
  } else
    p->s.ptr = bp;
  freep = p;
}
    1189:	5b                   	pop    %ebx
    118a:	5e                   	pop    %esi
    118b:	5f                   	pop    %edi
    118c:	c3                   	ret    
    118d:	8d 76 00             	lea    0x0(%esi),%esi

00001190 <malloc>:
  return freep;
}

void*
malloc(uint nbytes)
{
    1190:	57                   	push   %edi
    1191:	56                   	push   %esi
    1192:	53                   	push   %ebx
    1193:	83 ec 10             	sub    $0x10,%esp
  Header *p, *prevp;
  uint nunits;

  nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
  if((prevp = freep) == 0){
    1196:	8b 15 c4 19 00 00    	mov    0x19c4,%edx
malloc(uint nbytes)
{
  Header *p, *prevp;
  uint nunits;

  nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
    119c:	8b 5c 24 20          	mov    0x20(%esp),%ebx
    11a0:	83 c3 07             	add    $0x7,%ebx
    11a3:	c1 eb 03             	shr    $0x3,%ebx
    11a6:	83 c3 01             	add    $0x1,%ebx
  if((prevp = freep) == 0){
    11a9:	85 d2                	test   %edx,%edx
    11ab:	0f 84 9d 00 00 00    	je     124e <malloc+0xbe>
    11b1:	8b 02                	mov    (%edx),%eax
    11b3:	8b 48 04             	mov    0x4(%eax),%ecx
    base.s.ptr = freep = prevp = &base;
    base.s.size = 0;
  }
  for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
    if(p->s.size >= nunits){
    11b6:	39 d9                	cmp    %ebx,%ecx
    11b8:	73 6e                	jae    1228 <malloc+0x98>
        p->s.size -= nunits;
        p += p->s.size;
        p->s.size = nunits;
      }
      freep = prevp;
      return (void*) (p + 1);
    11ba:	8d 3c dd 00 00 00 00 	lea    0x0(,%ebx,8),%edi
    11c1:	eb 0e                	jmp    11d1 <malloc+0x41>
    11c3:	90                   	nop
    11c4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
  if((prevp = freep) == 0){
    base.s.ptr = freep = prevp = &base;
    base.s.size = 0;
  }
  for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
    11c8:	8b 02                	mov    (%edx),%eax
    if(p->s.size >= nunits){
    11ca:	8b 48 04             	mov    0x4(%eax),%ecx
    11cd:	39 cb                	cmp    %ecx,%ebx
    11cf:	76 57                	jbe    1228 <malloc+0x98>
        p->s.size = nunits;
      }
      freep = prevp;
      return (void*) (p + 1);
    }
    if(p == freep)
    11d1:	3b 05 c4 19 00 00    	cmp    0x19c4,%eax
    11d7:	89 c2                	mov    %eax,%edx
    11d9:	75 ed                	jne    11c8 <malloc+0x38>
morecore(uint nu)
{
  char *p;
  Header *hp;

  if(nu < PAGE)
    11db:	81 fb ff 0f 00 00    	cmp    $0xfff,%ebx
    11e1:	b8 00 80 00 00       	mov    $0x8000,%eax
    nu = PAGE;
    11e6:	be 00 10 00 00       	mov    $0x1000,%esi
morecore(uint nu)
{
  char *p;
  Header *hp;

  if(nu < PAGE)
    11eb:	76 04                	jbe    11f1 <malloc+0x61>
    11ed:	89 f8                	mov    %edi,%eax
    11ef:	89 de                	mov    %ebx,%esi
    nu = PAGE;
  p = sbrk(nu * sizeof(Header));
    11f1:	89 04 24             	mov    %eax,(%esp)
    11f4:	e8 f3 fc ff ff       	call   eec <sbrk>
  if(p == (char*) -1)
    11f9:	83 f8 ff             	cmp    $0xffffffff,%eax
    11fc:	74 1a                	je     1218 <malloc+0x88>
    return 0;
  hp = (Header*)p;
  hp->s.size = nu;
    11fe:	89 70 04             	mov    %esi,0x4(%eax)
  free((void*)(hp + 1));
    1201:	83 c0 08             	add    $0x8,%eax
    1204:	89 04 24             	mov    %eax,(%esp)
    1207:	e8 04 ff ff ff       	call   1110 <free>
  return freep;
    120c:	8b 15 c4 19 00 00    	mov    0x19c4,%edx
      }
      freep = prevp;
      return (void*) (p + 1);
    }
    if(p == freep)
      if((p = morecore(nunits)) == 0)
    1212:	85 d2                	test   %edx,%edx
    1214:	75 b2                	jne    11c8 <malloc+0x38>
    1216:	66 90                	xchg   %ax,%ax
        return 0;
  }
}
    1218:	83 c4 10             	add    $0x10,%esp
      freep = prevp;
      return (void*) (p + 1);
    }
    if(p == freep)
      if((p = morecore(nunits)) == 0)
        return 0;
    121b:	31 c0                	xor    %eax,%eax
  }
}
    121d:	5b                   	pop    %ebx
    121e:	5e                   	pop    %esi
    121f:	5f                   	pop    %edi
    1220:	c3                   	ret    
    1221:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
    base.s.ptr = freep = prevp = &base;
    base.s.size = 0;
  }
  for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
    if(p->s.size >= nunits){
      if(p->s.size == nunits)
    1228:	39 cb                	cmp    %ecx,%ebx
    122a:	74 1c                	je     1248 <malloc+0xb8>
        prevp->s.ptr = p->s.ptr;
      else {
        p->s.size -= nunits;
    122c:	29 d9                	sub    %ebx,%ecx
    122e:	89 48 04             	mov    %ecx,0x4(%eax)
        p += p->s.size;
    1231:	8d 04 c8             	lea    (%eax,%ecx,8),%eax
        p->s.size = nunits;
    1234:	89 58 04             	mov    %ebx,0x4(%eax)
      }
      freep = prevp;
    1237:	89 15 c4 19 00 00    	mov    %edx,0x19c4
    }
    if(p == freep)
      if((p = morecore(nunits)) == 0)
        return 0;
  }
}
    123d:	83 c4 10             	add    $0x10,%esp
        p->s.size -= nunits;
        p += p->s.size;
        p->s.size = nunits;
      }
      freep = prevp;
      return (void*) (p + 1);
    1240:	83 c0 08             	add    $0x8,%eax
    }
    if(p == freep)
      if((p = morecore(nunits)) == 0)
        return 0;
  }
}
    1243:	5b                   	pop    %ebx
    1244:	5e                   	pop    %esi
    1245:	5f                   	pop    %edi
    1246:	c3                   	ret    
    1247:	90                   	nop
    base.s.size = 0;
  }
  for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
    if(p->s.size >= nunits){
      if(p->s.size == nunits)
        prevp->s.ptr = p->s.ptr;
    1248:	8b 08                	mov    (%eax),%ecx
    124a:	89 0a                	mov    %ecx,(%edx)
    124c:	eb e9                	jmp    1237 <malloc+0xa7>
  Header *p, *prevp;
  uint nunits;

  nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
  if((prevp = freep) == 0){
    base.s.ptr = freep = prevp = &base;
    124e:	c7 05 c4 19 00 00 c8 	movl   $0x19c8,0x19c4
    1255:	19 00 00 
    base.s.size = 0;
    1258:	b8 c8 19 00 00       	mov    $0x19c8,%eax
  Header *p, *prevp;
  uint nunits;

  nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
  if((prevp = freep) == 0){
    base.s.ptr = freep = prevp = &base;
    125d:	c7 05 c8 19 00 00 c8 	movl   $0x19c8,0x19c8
    1264:	19 00 00 
    base.s.size = 0;
    1267:	c7 05 cc 19 00 00 00 	movl   $0x0,0x19cc
    126e:	00 00 00 
    1271:	e9 44 ff ff ff       	jmp    11ba <malloc+0x2a>
